Leetcode Top Interview โœจ
GithubLinkedinXOfficial Website
  • Leetcode Top Interview ๐ŸŽฏ
  • Guide to Calculating Algorithm Complexity ๐Ÿš€
  • Topic 1 Array - String
    • 88. Merge Sorted Arrays ๐Ÿงฉ
    • 27. Remove Element ๐Ÿงน
    • 26. Remove Duplicates from Sorted Array ๐Ÿšซ
    • 80. Remove Duplicates from Sorted Array II ๐Ÿšซ๐Ÿšซ
    • 169. Majority Element ๐Ÿ‘‘
    • 189. Rotate Array ๐Ÿ”„
    • 121. Best Time to Buy and Sell Stock ๐Ÿ“ˆ
    • 122. Best Time to Buy and Sell Stock II ๐Ÿ“ˆ๐Ÿ’ฐ
    • 55. Jump Game ๐Ÿƒโ€โ™‚๏ธ
    • 45. Jump Game II ๐Ÿƒโ€โ™‚๏ธ
    • 274. H-Index ๐Ÿ“Š
    • 380. Insert Delete GetRandom O(1) ๐ŸŽฒ
    • 238. Product of Array Except Self ๐Ÿ”„
    • 134. Gas Station โ›ฝ
    • 135. Candy ๐Ÿฌ
    • 42. Trapping Rain Water ๐ŸŒง๏ธ
    • 13. Roman to Integer ๐Ÿ”ข
    • 018 Integer to Roman
    • 58. Length of Last Word ๐Ÿ” 
    • 14. Longest Common Prefix ๐ŸŒฑ
    • 151. Reverse Words in a String ๐Ÿ”„
    • 6. Zigzag Conversion ๐Ÿ”€
    • 28. Find the Index of the First Occurrence in a String ๐Ÿ”„
    • 68. Text Justification ๐Ÿ”„
  • Topic 2 Two Pointers
    • 125. Valid Palindrome ๐Ÿšฆ
    • 392. Is Subsequence ๐Ÿ“
    • 167. Two Sum II - Input Array Is Sorted ๐Ÿ”
    • 11. Container With Most Water ๐Ÿž๏ธ
    • 15. 3Sum ๐ŸŒ
  • Topic 3 Sliding Window
    • 209. Minimum Size Subarray Sum ๐ŸŒ
    • 3. Longest Substring Without Repeating Characters ๐ŸŒ
    • 30. Substring with Concatenation of All Words ๐ŸŒ
    • 76. Minimum Window Substring ๐ŸŒ
  • Topic 4 Matrix
    • 36. Valid Sudoku ๐ŸŒ
    • 54. Spiral Matrix ๐ŸŒ
    • 48. Rotate Image ๐Ÿ”„
    • 73. Set Matrix Zeroes
    • 289. Game of Life ๐Ÿ–ผ๏ธ
  • Topic 5 Hashmap
    • 383. Ransom Note ๐Ÿ”
    • 205. Isomorphic Strings ๐Ÿ”
    • 290. Word Pattern ๐Ÿงฉ
    • 242. Valid Anagram ๐ŸŽข
    • 49. Group Anagrams ๐Ÿคนโ€โ™‚๏ธ
    • 1. Two Sum ๐Ÿ”
    • 202. Happy Number ๐Ÿคฉ
    • 219. Contains Duplicate II ๐Ÿ”
    • 128. Longest Consecutive Sequence ๐Ÿ”
  • Topic 6 Intervals
    • 228. Summary Ranges ๐Ÿ“Š
    • 56. Merge Intervals ๐Ÿ”€
    • 57. Insert Interval ๐Ÿ†•
    • 452. Minimum Number of Arrows to Burst Balloons ๐ŸŽˆ
  • Topic 7 Stack
    • 20. Valid Parentheses ๐Ÿ”
    • 71. Simplify Path ๐Ÿ—บ๏ธ
    • 155. Min Stack ๐Ÿ—ƒ๏ธ
    • 150. Evaluate Reverse Polish Notation ๐Ÿง ๐Ÿ’ป
    • 224. Basic Calculator ๐Ÿงฎ
  • Topic 8 Linked List
    • 141. Linked List Cycle ๐Ÿ”
    • 2. Add Two Numbers ๐Ÿ”ข
    • 21. Merge Two Sorted Lists ๐Ÿ”—
    • 138. Copy List with Random Pointer ๐Ÿ”—
    • 92. Reverse Linked List II ๐Ÿ”„
      • Letโ€™s explain step by step ๐Ÿ‡
    • 25. Reverse Nodes in k-Group ๐Ÿ”„
    • 19. Remove Nth Node From End of List ๐Ÿ—‘๏ธ
    • 82. Remove Duplicates from Sorted List II โŒ๐Ÿ”ข
    • 61. Rotate List ๐Ÿ”„
    • 86. Partition List ๐Ÿ”—
    • 146. LRU Cache ๐Ÿ”—
  • Topic 9 Binary Tree General
    • 104. Maximum Depth of Binary Tree ๐Ÿ”—
    • 100. Same Tree ๐Ÿ”—
    • 226. Invert Binary Tree ๐Ÿ”—
    • 101. Symmetric Tree ๐Ÿ”—
    • 105. Construct Binary Tree from Preorder and Inorder Traversal ๐Ÿ”—
    • 106. Construct Binary Tree from Inorder and Postorder Traversal ๐Ÿ”—
    • 117. Populating Next Right Pointers in Each Node II ๐Ÿ”—
    • 114. Flatten Binary Tree to Linked List ๐Ÿ”—
    • 112. Path Sum ๐Ÿ”—
    • 129. Sum Root to Leaf Numbers ๐Ÿ”—
      • What_is_DFS
    • 124. Binary Tree Maximum Path Sum ๐Ÿ”—
Powered by GitBook
On this page
  • Table of Contents ๐Ÿ“–
  • What is Leetcode? ๐Ÿง‘โ€๐Ÿ’ป
  • About the Top Interview 150 Collection ๐Ÿ†
  • Tips for Solving Problems ๐Ÿ’ก
  • Repository Structure ๐Ÿ—‚๏ธ
  • How to Use This Repository ๐Ÿš€
  • Resources ๐Ÿ“š

Was this helpful?

Leetcode Top Interview ๐ŸŽฏ

NextGuide to Calculating Algorithm Complexity ๐Ÿš€

Last updated 3 months ago

Was this helpful?

This repository contains solutions to the Leetcode Top Interview 150 problems.

These problems are commonly asked in technical interviews and cover a wide range of topics, including data structures, algorithms, and problem-solving techniques.

Show some โค๏ธ by starring โญ this repository if you like it!

Contact for work, email: chunhthanhde.dev@gmail.com

Table of Contents ๐Ÿ“–

What is Leetcode? ๐Ÿง‘โ€๐Ÿ’ป

About the Top Interview 150 Collection ๐Ÿ†

The Top Interview 150 collection on Leetcode is a curated set of 150 interview questions that top tech companies frequently ask. These questions are carefully selected to cover essential concepts and algorithms that interviewers expect candidates to be familiar with.

Id
Problem
Difficulty
Signal
Status

Array / String

1

Easy

๐ŸŸข

โœ…

2

Easy

๐ŸŸข

โœ…

3

Easy

๐ŸŸข

โœ…

4

Medium

๐ŸŸก

โœ…

5

Easy

๐ŸŸข

โœ…

6

Medium

๐ŸŸก

โœ…

7

Easy

๐ŸŸข

โœ…

8

Medium

๐ŸŸก

โœ…

9

Medium

๐ŸŸก

โœ…

10

Medium

๐ŸŸก

โœ…

11

Medium

๐ŸŸก

โœ…

12

Medium

๐ŸŸก

โœ…

13

Medium

๐ŸŸก

โœ…

14

Medium

๐ŸŸก

โœ…

15

Hard

๐Ÿ”ด

โœ…

16

Hard

๐Ÿ”ด

โœ…

17

Easy

๐ŸŸข

โœ…

18

Medium

๐ŸŸก

โœ…

19

Easy

๐ŸŸข

โœ…

20

Easy

๐ŸŸข

โœ…

21

Medium

๐ŸŸก

โœ…

22

Medium

๐ŸŸก

โœ…

23

Easy

๐ŸŸข

โœ…

24

Hard

๐Ÿ”ด

โœ…

Two Pointers

25

Easy

๐ŸŸข

โœ…

26

Easy

๐ŸŸข

โœ…

27

Medium

๐ŸŸก

โœ…

28

Medium

๐ŸŸก

โœ…

29

Medium

๐ŸŸก

โœ…

Sliding Window

30

Medium

๐ŸŸก

โœ…

31

Medium

๐ŸŸก

โœ…

32

Hard

๐Ÿ”ด

โœ…

33

Hard

๐Ÿ”ด

โœ…

Matrix

34

Medium

๐ŸŸก

โœ…

35

Medium

๐ŸŸก

โœ…

36

Medium

๐ŸŸก

โœ…

37

Medium

๐ŸŸก

โœ…

38

Medium

๐ŸŸก

โœ…

Hashmap

39

Easy

๐ŸŸข

โœ…

40

Easy

๐ŸŸข

โœ…

41

Easy

๐ŸŸข

โœ…

42

Easy

๐ŸŸข

โœ…

43

Medium

๐ŸŸก

โœ…

44

Easy

๐ŸŸข

โœ…

45

Easy

๐ŸŸข

โœ…

46

Easy

๐ŸŸข

โœ…

47

Medium

๐ŸŸก

โœ…

Intervals

48

Easy

๐ŸŸข

โœ…

49

Medium

๐ŸŸก

โœ…

50

Medium

๐ŸŸก

โœ…

51

Medium

๐ŸŸก

โœ…

Stack

52

Easy

๐ŸŸข

โœ…

53

Medium

๐ŸŸก

โœ…

54

Medium

๐ŸŸก

โœ…

55

Medium

๐ŸŸก

โœ…

56

Hard

๐Ÿ”ด

โœ…

Linked List

57

Easy

๐ŸŸข

โœ…

58

Medium

๐ŸŸก

โœ…

59

Easy

๐ŸŸข

โœ…

60

Medium

๐ŸŸก

โœ…

61

Medium

๐ŸŸก

โœ…

62

Hard

๐Ÿ”ด

โœ…

63

Medium

๐ŸŸก

โœ…

64

Medium

๐ŸŸก

โœ…

65

Medium

๐ŸŸก

โœ…

66

Medium

๐ŸŸก

โœ…

67

Medium

๐ŸŸก

โœ…

Binary Tree General

68

Easy

๐ŸŸข

โœ…

69

Easy

๐ŸŸข

โœ…

70

Easy

๐ŸŸข

โœ…

71

Easy

๐ŸŸข

โœ…

72

Medium

๐ŸŸก

โœ…

73

Medium

๐ŸŸก

โœ…

74

Medium

๐ŸŸก

โœ…

75

Flatten Binary Tree to Linked List

Medium

๐ŸŸก

76

Path Sum

Easy

๐ŸŸข

77

Sum Root to Leaf Numbers

Medium

๐ŸŸก

78

Binary Tree Maximum Path Sum

Hard

๐Ÿ”ด

79

Binary Search Tree Iterator

Medium

๐ŸŸก

80

Count Complete Tree Nodes

Easy

๐ŸŸข

81

Lowest Common Ancestor of a Binary Tree

Medium

๐ŸŸก

Binary Tree BFS

8282

Binary Tree Right Side View

Medium

๐ŸŸก

83

Average of Levels in Binary Tree

Easy

๐ŸŸข

84

Binary Tree Level Order Traversal

Medium

๐ŸŸก

85

Binary Tree Zigzag Level Order Traversal

Medium

๐ŸŸก

Binary Search Tree

86

Minimum Absolute Difference in BST

Easy

๐ŸŸข

87

Kth Smallest Element in a BST

Medium

๐ŸŸก

88

Validate Binary Search Tree

Medium

๐ŸŸก

Graph General

89

Number of Islands

Medium

๐ŸŸก

90

Surrounded Regions

Medium

๐ŸŸก

91

Clone Graph

Medium

๐ŸŸก

92

Evaluate Division

Medium

๐ŸŸก

93

Course Schedule

Medium

๐ŸŸก

94

Course Schedule II

Medium

๐ŸŸก

Graph BFS

95

Snakes and Ladders

Medium

๐ŸŸก

96

Minimum Genetic Mutation

Medium

๐ŸŸก

97

Word Ladder

Hard

๐Ÿ”ด

Trie

98

Implement Trie (Prefix Tree)

Medium

๐ŸŸก

99

Design Add and Search Words Data Structure

Medium

๐ŸŸก

100

Word Search II

Hard

๐Ÿ”ด

Backtracking

101

Letter Combinations of a Phone Number

Medium

๐ŸŸก

102

Combinations

Medium

๐ŸŸก

103

Permutations

Medium

๐ŸŸก

104

Combination Sum

Medium

๐ŸŸก

105

N-Queens II

Hard

๐Ÿ”ด

106

Generate Parentheses

Medium

๐ŸŸก

107

Word Search

Medium

๐ŸŸก

Divide & Conquer

108

Convert Sorted Array to Binary Search Tree

Easy

๐ŸŸข

109

Sort List

Medium

๐ŸŸก

110

Construct Quad Tree

Medium

๐ŸŸก

111

Merge k Sorted Lists

Hard

๐Ÿ”ด

Kadane's Algorithm

112

Maximum Subarray

Medium

๐ŸŸก

113

Maximum Sum Circular Subarray

Medium

๐ŸŸก

Binary Search

114

Search Insert Position

Easy

๐ŸŸข

115

Search a 2D Matrix

Medium

๐ŸŸก

116

Find Peak Element

Medium

๐ŸŸก

117

Search in Rotated Sorted Array

Medium

๐ŸŸก

118

Find First and Last Position of Element in Sorted Array

Medium

๐ŸŸก

119

Find Minimum in Rotated Sorted Array

Medium

๐ŸŸก

120

Median of Two Sorted Arrays

Hard

๐Ÿ”ด

Heap

121

Kth Largest Element in an Array

Medium

๐ŸŸก

122

IPO

Hard

๐Ÿ”ด

123

Find K Pairs with Smallest Sums

Medium

๐ŸŸก

124

Find Median from Data Stream

Hard

๐Ÿ”ด

Bit Manipulation

125

Add Binary

Easy

๐ŸŸข

126

Reverse Bits

Easy

๐ŸŸข

127

Number of 1 Bits

Easy

๐ŸŸข

128

Single Number

Easy

๐ŸŸข

129

Single Number II

Medium

๐ŸŸก

130

Bitwise AND of Numbers Range

Medium

๐ŸŸก

Math

131

Palindrome Number

Easy

๐ŸŸข

132

Plus One

Easy

๐ŸŸข

133

Factorial Trailing Zeroes

Medium

๐ŸŸก

134

Sqrt(x)

Easy

๐ŸŸข

135

Pow(x, n)

Medium

๐ŸŸก

136

Max Points on a Line

Hard

๐Ÿ”ด

1D DP

137

Climbing Stairs

Easy

๐ŸŸข

138

House Robber

Medium

๐ŸŸก

139

Word Break

Medium

๐ŸŸก

140

Coin Change

Medium

๐ŸŸก

141

Longest Increasing Subsequence

Medium

๐ŸŸก

Multidimensional DP

142

Triangle

Medium

๐ŸŸก

143

Minimum Path Sum

Medium

๐ŸŸก

144

Unique Paths II

Medium

๐ŸŸก

145

Longest Palindromic Substring

Medium

๐ŸŸก

146

Interleaving String

Medium

๐ŸŸก

147

Edit Distance

Medium

๐ŸŸก

148

Best Time to Buy and Sell Stock III

Hard

๐Ÿ”ด

149

Best Time to Buy and Sell Stock IV

Hard

๐Ÿ”ด

150

Maximal Square

Medium

๐ŸŸก

Tips for Solving Problems ๐Ÿ’ก

SSome helpful strategies to tackle different types of problems in this repository:

Strategy

Description

Example Use Case

Heap for Top K Elements ๐Ÿ”ผ

Use a Heap to find the top K largest, smallest, or closest elements among N elements. Efficient for problems requiring constant updates.

Finding the top K largest numbers in a list.

Binary Search or Two Pointers for Sorted Input ๐Ÿ”โžก๏ธโฌ…๏ธ

Use Binary Search or Two Pointers for sorted arrays, lists, or matrices to optimize the solution.

Searching for an element in a sorted array.

Backtracking or BFS for Combinations and Permutations ๐Ÿ”„๐Ÿ”

Use Backtracking or BFS for problems requiring exploration of all combinations or permutations.

Finding all permutations of a set.

BFS or DFS for Trees and Graphs ๐ŸŒณ๐Ÿ”—

Use BFS or DFS for tree or graph-related problems.

Searching a graph or binary tree.

Stack for Converting Recursion to Iteration ๐Ÿ“š

Convert recursion problems into iterative solutions using a stack to simulate the call stack.

Performing a recursive search without using recursion.

Optimizing Array Problems ๐Ÿ“Š

Optimize array problems from O(nยฒ) to O(n) using a HashMap or Set, or to O(n log n) using sorting.

Finding duplicate elements in an array.

Dynamic Programming for Optimization Problems ๐Ÿš€

Dynamic Programming is essential for problems that involve maximizing or minimizing values, using results from previous subproblems.

Finding the maximum value in a sequence.

Trie for String Manipulation ๐Ÿ”ค

For multiple strings or searching for common substrings, use a Trie or HashMap. A Trie is the most suitable data structure when manipulating multiple strings.

Searching or manipulating multiple strings efficiently.

Fast & Slow Pointers for Linked Lists ๐Ÿ”„๐Ÿƒโ€โ™‚๏ธ๐Ÿƒโ€โ™€๏ธ

Use Fast & Slow Pointers to efficiently solve LinkedList problems with restricted memory usage, like detecting cycles or finding the middle element.

Detecting cycles or finding the middle of a linked list.

Repository Structure ๐Ÿ—‚๏ธ

This repository is organized by problem number, with each problem having its own directory.

Inside each problem directory, you will find the solution file(s) along with a README file that provides a problem description, constraints, and additional notes if necessary.

How to Use This Repository ๐Ÿš€

Navigate through the problem directories to explore solutions. Each directory contains the solution files, including explanations and sample input/output.

You can practice implementing your solutions and compare them with those provided.

Feel free to contribute by submitting your solutions or improvements. Open a pull request to share your contributions.

I recommend contributions for new languages, as currently, the solution is only available in Java ๐Ÿ›.

Resources ๐Ÿ“š

Happy coding and good luck with your interview preparation! ๐ŸŽ‰

GitHub stars
GitHub forks
GitHub watchers
linkedin

is a popular online platform that provides a collection of coding challenges. Software engineers and interview candidates widely use it to practice coding skills and prepare for technical interviews. Leetcode offers many problems to solve, classified by difficulty level and topic.

Leetcode
Leetcode
Top 150 Interview Questions - Leetcode
GitBook Solution
What is Leetcode? ๐Ÿง‘โ€๐Ÿ’ป
About the Top Interview 150 Collection Questions ๐Ÿ†
Tips for Solving Problems ๐Ÿ’ก
Repository Structure ๐Ÿ—‚๏ธ
How to Use This Repository ๐Ÿš€
Resources ๐Ÿ“š
Merge Sorted Array
Remove Element
Remove Duplicates from Sorted Array
Remove Duplicates from Sorted Array II
Majority Element
Rotate Array
Best Time to Buy and Sell Stock
Best Time to Buy and Sell Stock II
Jump Game
Jump Game II
H-Index
Insert Delete GetRandom O(1)
Product of Array Except Self
Gas Station
Candy
Trapping Rain Water
Roman to Integer
Integer to Roman
Length of Last Word
Longest Common Prefix
Reverse Words in a String
Zigzag Conversion
Find the Index of the First Occurrence in a String
Text Justification
Valid Palindrome
Is Subsequence
Two Sum II - Input Array Is Sorted
Container With Most Water
3Sum
Minimum Size Subarray Sum
Longest Substring Without Repeating Characters
Substring with Concatenation of All Words
Minimum Window Substring
Valid Sudoku
Spiral Matrix
Rotate Image
Set Matrix Zeroes
Game of Life
Ransom Note
Isomorphic Strings
Word Pattern
Valid Anagram
Group Anagrams
Two Sum
Happy Number
Contains Duplicate II
Longest Consecutive Sequence
Summary Ranges
Merge Intervals
Insert Interval
Minimum Number of Arrows to Burst Balloons
Valid Parentheses
Simplify Path
Min Stack
Evaluate Reverse Polish Notation
Basic Calculator
Linked List Cycle
Add Two Numbers
Merge Two Sorted Lists
Copy List with Random Pointer
Reverse Linked List II
Reverse Nodes in k-Group
Remove Nth Node From End of List
Remove Duplicates from Sorted List II
Rotate List
Partition List
LRU Cache
Maximum Depth of Binary Tree
Same Tree
Invert Binary Tree
Symmetric Tree
Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal
Populating Next Right Pointers in Each Node II