LeetCode is the best platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.
Our top interview questions are divided into levels of difficulty of problems like Easy, Medium, and Hard to help you master Data Structure & Algorithms and improve your coding skills.
List of LeetCode solutions along with related topics. Solutions in different programming languages like C++, Java, JavaScript, and Python.
# | Problem | Level | Solution |
1 | Remove Invalid Parentheses | Hard | Link |
2 | Palindrome Pairs | Hard | Link |
3 | Word Ladder II | Hard | Link |
4 | Word Ladder | Hard | Link |
5 | Sliding Window Maximum | Hard | Link |
6 | Serialize and Deserialize Binary Tree | Hard | Link |
7 | Patching Array | Hard | Link |
8 | Longest Increasing Path in a Matrix | Hard | Link |
9 | Count of Range Sum | Hard | Link |
10 | Create Maximum Number | Hard | Link |
11 | Count of Smaller Numbers After Self | Hard | Link |
12 | Burst Balloons | Hard | Link |
13 | Find Median from Data Stream | Hard | Link |
14 | Basic Calculator | Hard | Link |
15 | Shortest Palindrome | Hard | Link |
16 | Maximum Sum of 3 Non Overlapping Subarrays | Hard | Link |
17 | Reconstruct Itinerary | Hard | Link |
18 | Decode Ways II | Hard | Link |
19 | Expression Add Operators | Hard | Link |
20 | Integer to English Words | Hard | Link |
21 | The Skyline Problem | Hard | Link |
22 | Word Break II | Hard | Link |
23 | Zuma Game | Hard | Link |
24 | Arithmetic Slices II Subsequence | Hard | Link |
25 | Split Array Largest Sum | Hard | Link |
26 | Binary Tree Maximum Path Sum | Hard | Link |
27 | Max Points on a Line | Hard | Link |
28 | Cut Off Trees for Golf Event | Hard | Link |
29 | Super Washing Machines | Hard | Link |
30 | LFU Cache | Hard | Link |
31 | Russian Doll Envelopes | Hard | Link |
32 | Max Sum of Rectangle No Larger Than K | Hard | Link |
33 | Perfect Rectangle | Hard | Link |
34 | Trapping Rain Water II | Hard | Link |
35 | Sliding Window Median | Hard | Link |
36 | Smallest Good Base | Hard | Link |
37 | Reverse Pairs | Hard | Link |
38 | Freedom Trail | Hard | Link |
39 | Student Attendance Record II | Hard | Link |
40 | Erect the Fence | Hard | Link |
41 | Kth Smallest Number in Multiplication Table | Hard | Link |
42 | 24 Game | Hard | Link |
43 | Redundant Connection II | Hard | Link |
44 | Find K-th Smallest Pair Distance | Hard | Link |
45 | Number of Atoms | Hard | Link |
46 | Best Time to Buy and Sell Stock III | Hard | Link |
47 | Count Different Palindromic Subsequences | Hard | Link |
48 | Dungeon Game | Hard | Link |
49 | Tag Validator | Hard | Link |
50 | Frog Jump | Hard | Link |
51 | All One Data Structure | Hard | Link |
52 | Falling Squares | Hard | Link |
53 | Largest Palindrome Product | Hard | Link |
54 | Insert Delete Get random O(1) Duplicates Allowed | Hard | Link |
55 | Find the Closest Palindrome | Hard | Link |
56 | Distinct Subsequences | Hard | Link |
57 | K-th Smallest in Lexicographical Order | Hard | Link |
58 | Palindrome Partitioning II | Hard | Link |
59 | Find Minimum in Rotated Sorted Array II | Hard | Link |
60 | Candy | Hard | Link |
61 | Best Time to Buy and Sell Stock IV | Hard | Link |
62 | Number of Digit One | Hard | Link |
63 | Self Crossing | Hard | Link |
64 | Data Stream as Disjoint Intervals | Hard | Link |
65 | Strong Password Checker | Hard | Link |
66 | Poor Pigs | Hard | Link |
67 | Count the Repetitions | Hard | Link |
68 | Concatenated Words | Hard | Link |
69 | IPO | Hard | Link |
70 | Remove Boxes | Hard | Link |
71 | Non Negative Integers without Consecutive Ones | Hard | Link |
72 | K-Inverse Pairs Array | Hard | Link |
73 | Course Schedule III | Hard | Link |
74 | Smallest Range Covering Elements from K Lists | Hard | Link |
75 | Strange Printer | Hard | Link |
76 | Stickers to Spell Word | Hard | Link |
77 | Random Pick with Blacklist | Hard | Link |
78 | Range Module | Hard | Link |
79 | Parse Lisp Expression | Hard | Link |
80 | My Calendar III | Hard | Link |
81 | Cherry Pickup | Hard | Link |
82 | Prefix and Suffix Search | Hard | Link |
83 | Cracking the Safe | Hard | Link |
84 | Contain Virus | Hard | Link |
85 | Set Intersection Size at least Two | Hard | Link |
86 | Couples Holding Hands | Hard | Link |
87 | Basic Calculator IV | Hard | Link |
88 | Sliding Puzzle | Hard | Link |
89 | Swim in Rising Water | Hard | Link |
90 | Reaching Points | Hard | Link |
91 | Transform to Chessboard | Hard | Link |
92 | Preimage Size of Factorial Zeroes Function | Hard | Link |
93 | Smallest Rotation with Highest Score | Hard | Link |
94 | Special Binary String | Hard | Link |
95 | Max Chunks to Make Sorted II | Hard | Link |
96 | Human Traffic of Stadium | Hard | Link |
97 | Department Top Three Salaries | Hard | Link |
98 | Trips and Users | Hard | Link |
99 | Number of Transactions Per Visit | Hard | Link |
100 | Report Contiguous Dates | Hard | Link |
101 | Valid Number | Hard | Link |
102 | Permutation Sequence | Hard | Link |
103 | N Queens II | Hard | Link |
104 | Minimum Window Substring | Hard | Link |
105 | Scramble String | Hard | Link |
106 | Maximal Rectangle | Hard | Link |
107 | N-Queens | Hard | Link |
108 | Wildcard Matching | Hard | Link |
109 | Trapping Rain Water | Hard | Link |
110 | First Missing Positive | Hard | Link |
111 | Longest Valid Parentheses | Hard | Link |
112 | Largest Rectangle in Histogram | Hard | Link |
113 | Sudoku Solver | Hard | Link |
114 | Substring with Concatenation of All Words | Hard | Link |
115 | Reverse Nodes in K-Group | Hard | Link |
116 | Regular Expression Matching | Hard | Link |
117 | Merge K-Sorted Lists | Hard | Link |
118 | Text Justification | Hard | Link |
119 | Contains Duplicate III | Hard | Link |
120 | Word Search II | Hard | Link |
121 | Maximum Sum of 3 Non-Overlapping Subarrays | Hard | Link |
# | Problem | Level | Solution |
1 | Binary Tree Level Order Traversal | Medium | Link |
2 | Water And Jug Problem | Medium | Link |
3 | Beautiful Arrangement | Medium | Link |
4 | Longest Word in Dictionary through Deleting | Medium | Link |
5 | Longest Uncommon Subsequence II | Medium | Link |
6 | Predict the Winner | Medium | Link |
7 | Magical String | Medium | Link |
8 | Heaters | Medium | Link |
9 | Ones and Zeroes | Medium | Link |
10 | Number of Boomerangs | Medium | Link |
11 | Maximum XOR of Two Numbers in an Array | Medium | Link |
12 | Queue Reconstruction by Height | Medium | Link |
13 | Combination Sum IV | Medium | Link |
14 | Pacific Atlantic Water Flow | Medium | Link |
15 | Exclusive Time of Functions | Medium | Link |
16 | Continuous Subarray Sum | Medium | Link |
17 | Target Sum | Medium | Link |
18 | Total Hamming Distance | Medium | Link |
19 | Random Pick Index | Medium | Link |
20 | Flatten Nested List Iterator | Medium | Link |
21 | Increasing Triplet Subsequence | Medium | Link |
22 | H-Index II | Medium | Link |
23 | Design Add and Search Words Data Structure | Medium | Link |
24 | Course Schedule II | Medium | Link |
25 | Minimum Size Subarray Sum | Medium | Link |
26 | Binary Search Tree Iterator | Medium | Link |
27 | Clone Graph | Medium | Link |
28 | Longest Consecutive Sequence | Medium | Link |
29 | Partition Equal Subset Sum | Medium | Link |
30 | Game of Life | Medium | Link |
31 | Best Time to Buy and Sell Stock with Transaction Fee | Medium | Link |
32 | Trim a Binary Search Tree | Medium | Link |
33 | Next Greater Element III | Medium | Link |
34 | Number of Provinces | Medium | Link |
35 | Add Two Numbers II | Medium | Link |
36 | String Compression | Medium | Link |
37 | Lexicographical Numbers | Medium | Link |
38 | Find the Duplicate Number | Medium | Link |
39 | H-Index | Medium | Link |
40 | Kth Smallest Element in a BST | Medium | Link |
41 | Implement Trie Prefix Tree | Medium | Link |
42 | LRU Cache | Medium | Link |
43 | Factorial Trailing Zeroes | Medium | Link |
44 | Palindrome Partitioning | Medium | Link |
45 | Populating Next Right Pointers in Each Node II | Medium | Link |
46 | Path Sum II | Medium | Link |
47 | Construct Binary Tree from Preorder and Inorder Traversal | Medium | Link |
48 | Binary Tree Zigzag Level Order Traversal | Medium | Link |
49 | 3Sum Closest | Medium | Link |
50 | Container with Most Water | Medium | Link |
51 | Out of Boundary Paths | Medium | Link |
52 | Arithmetic Slices | Medium | Link |
53 | Integer Replacement | Medium | Link |
54 | Longest Substring with at least K Repeating Characters | Medium | Link |
55 | Peeking Iterator | Medium | Link |
56 | Course Schedule | Medium | Link |
57 | Compare Version Numbers | Medium | Link |
58 | Reverse Words in a String | Medium | Link |
59 | Reverse Integer | Medium | Link |
60 | Maximum Length of Pair Chain | Medium | Link |
61 | Convert BST to Greater Tree | Medium | Link |
62 | Solve the Equation | Medium | Link |
63 | Optimal Division | Medium | Link |
64 | Complex Number Multiplication | Medium | Link |
65 | Split Linked List in Parts | Medium | Link |
66 | Top K Frequent Words | Medium | Link |
67 | Maximum Width of Binary Tree | Medium | Link |
68 | Encode and Decode Tinyurl | Medium | Link |
69 | K Diff Pairs in an Array | Medium | Link |
70 | Minesweeper | Medium | Link |
71 | Longest Palindromic Subsequence | Medium | Link |
72 | Most Frequent Subtree Sum | Medium | Link |
73 | Sort Characters by Frequency | Medium | Link |
74 | Serialize and Deserialize BST | Medium | Link |
75 | Find All Anagrams in a String | Medium | Link |
76 | Rotate Function | Medium | Link |
77 | Insert Delete Getrandom O(1) | Medium | Link |
78 | Design Twitter | Medium | Link |
79 | Search a 2D Matrix II | Medium | Link |
80 | Product of Array Except Self | Medium | Link |
81 | Lowest Common Ancestor of a Binary Tree | Medium | Link |
82 | Lowest Common Ancestor of a Binary Search Tree | Medium | Link |
83 | Kth Largest Element in an Array | Medium | Link |
84 | Count Primes | Medium | Link |
85 | Number of Islands | Medium | Link |
86 | Binary Tree Right Side View | Medium | Link |
87 | Word Break | Medium | Link |
88 | Copy List with Random Pointer | Medium | Link |
89 | Letter Combinations of a Phone Number | Medium | Link |
90 | String to Integer | Medium | Link |
91 | Mini Parser | Medium | Link |
92 | Replace Words | Medium | Link |
93 | Minimum Height Trees | Medium | Link |
94 | Super Ugly Number | Medium | Link |
95 | Maximum Product of Word Lengths | Medium | Link |
96 | Wiggle Sort II | Medium | Link |
97 | Verify Preorder Serialization of a Binary Tree | Medium | Link |
98 | Count Numbers with Unique Digits | Medium | Link |
99 | Largest Divisible Subset | Medium | Link |
100 | Remove Duplicate Letters | Medium | Link |
101 | Find K Pairs with Smallest Sums | Medium | Link |
102 | Guess Number Higher or Lower II | Medium | Link |
103 | Kth Smallest Element in a Sorted Matrix | Medium | Link |
104 | Linked List Random Node | Medium | Link |
105 | Longest Absolute File Path | Medium | Link |
106 | UTF-8 Validation | Medium | Link |
107 | Decode String | Medium | Link |
108 | Evaluate Division | Medium | Link |
109 | Nth Digit | Medium | Link |
110 | Remove K Digits | Medium | Link |
111 | Diagonal Traverse | Medium | Link |
112 | Non Decreasing Array | Medium | Link |
113 | Split Array into Consecutive Subsequences | Medium | Link |
114 | Find K Closest Elements | Medium | Link |
115 | Find Duplicate Subtrees | Medium | Link |
116 | Delete Operation for Two Strings | Medium | Link |
117 | Shopping Offers | Medium | Link |
118 | Shortest Unsorted Continuous Subarray | Medium | Link |
119 | 01 Matrix | Medium | Link |
120 | Subarray Sum Equals K | Medium | Link |
121 | Construct Binary Tree from Inorder and Postorder Traversal | Medium | Link |
122 | Partition to K Equal Sum Subsets | Medium | Link |
123 | Sum of Square Numbers | Medium | Link |
124 | Find Largest Value in each Tree Row | Medium | Link |
125 | Can I Win | Medium | Link |
126 | Isomorphic Strings | Medium | Link |
127 | Friend Requests II Who has the Most Friends | Medium | Link |
128 | Beautiful Arrangement II | Medium | Link |
129 | Contiguous Array | Medium | Link |
130 | Brick Wall | Medium | Link |
131 | Task Scheduler | Medium | Link |
132 | Palindromic Substrings | Medium | Link |
133 | Maximum Swap | Medium | Link |
134 | Number of Longest Increasing Subsequence | Medium | Link |
135 | Accounts Merge | Medium | Link |
136 | Generate Parentheses | Medium | Link |
137 | Find Peak Element | Medium | Link |
138 | Fraction to Recurring Decimal | Medium | Link |
139 | Perfect Squares | Medium | Link |
140 | Best Time to Buy and Sell Stock with Cooldown | Medium | Link |
141 | Investments in 2016 | Medium | Link |
142 | Majority Element II | Medium | Link |
143 | Non Decreasing Subsequences | Medium | Link |
144 | Employee Importance | Medium | Link |
145 | Delete Node in a BST | Medium | Link |
146 | House Robber III | Medium | Link |
147 | Top K Frequent Elements | Medium | Link |
148 | Validate IP Address | Medium | Link |
149 | Minimum Genetic Mutation | Medium | Link |
150 | Integer to Roman | Medium | Link |
151 | Find All Duplicates in an Array | Medium | Link |
152 | Longest Repeating Character Replacement | Medium | Link |
153 | Remove Comments | Medium | Link |
154 | Bulb Switcher II | Medium | Link |
155 | Maximum Binary Tree | Medium | Link |
156 | 2 Keys Keyboard | Medium | Link |
157 | Permutation in String | Medium | Link |
158 | Find Bottom Left Tree Value | Medium | Link |
159 | Minimum Number of Arrows to Burst Balloons | Medium | Link |
160 | Battleships in a Board | Medium | Link |
161 | Longest Increasing Subsequence | Medium | Link |
162 | House Robber II | Medium | Link |
163 | Find Minimum in Rotated Sorted Array | Medium | Link |
164 | Populating Next Right Pointers in Each Node II | Medium | Link |
165 | Repeated DNA Sequences | Medium | Link |
166 | Maximum Product Subarray | Medium | Link |
167 | Evaluate Reverse Polish Notation | Medium | Link |
168 | 4Sum | Medium | Link |
169 | Minimum Moves to Equal Array Elements | Medium | Link |
170 | My Calendar II | Medium | Link |
171 | My Calendar I | Medium | Link |
172 | Longest Univalue Path | Medium | Link |
173 | Repeated String Match | Medium | Link |
174 | Redundant Connection | Medium | Link |
175 | Implement Magic Dictionary | Medium | Link |
176 | Populating Next Right Pointers in Each Node | Medium | Link |
177 | Flatten Binary Tree to Linked List | Medium | Link |
178 | Decode Ways | Medium | Link |
179 | Merge Intervals | Medium | Link |
180 | Running Total for Different Genders | Medium | Link |
181 | Team Scores in Football Tournament | Medium | Link |
182 | Highest Grade for each Student | Medium | Link |
183 | Restaurant Growth | Medium | Link |
184 | Find the Start and End Number of Continuous Ranges | Medium | Link |
185 | All People Report to the Given Manager | Medium | Link |
186 | Page Recommendations | Medium | Link |
187 | Last Person to Fit in the Bus | Medium | Link |
188 | Monthly Transactions I | Medium | Link |
189 | Product Price at a Given Date | Medium | Link |
190 | Immediate Food Delivery II | Medium | Link |
191 | Active Businesses | Medium | Link |
192 | Minimum Path Sum | Medium | Link |
193 | Unique Paths II | Medium | Link |
194 | Unique Paths | Medium | Link |
195 | Rotate List | Medium | Link |
196 | Project Employees III | Medium | Link |
197 | Spiral Matrix II | Medium | Link |
198 | Edit Distance | Medium | Link |
199 | Insert Interval | Medium | Link |
200 | Count And Say | Medium | Link |
201 | Product Sales Analysis III | Medium | Link |
202 | Two Sum II Input Array is Sorted | Medium | Link |
203 | Combinations | Medium | Link |
204 | Search a 2D Matrix | Medium | Link |
205 | Customers Who Bought All Products | Medium | Link |
206 | Set Matrix Zeroes | Medium | Link |
207 | Exchange Seats | Medium | Link |
208 | Shortest Distance in a Line | Medium | Link |
209 | Shortest Distance in a Plane | Medium | Link |
210 | Tree Node | Medium | Link |
211 | Managers with at Least 5 Direct Reports | Medium | Link |
212 | Game Play Analysis III | Medium | Link |
213 | Nth Highest Salary | Medium | Link |
214 | Rank Scores | Medium | Link |
215 | Consecutive Numbers | Medium | Link |
216 | Second Highest Salary | Medium | Link |
217 | Maximum Subarray | Medium | Link |
218 | Spiral Matrix | Medium | Link |
219 | Jump Game | Medium | Link |
220 | Validate Binary Search Tree | Medium | Link |
221 | Gray Code | Medium | Link |
222 | Subsets II | Medium | Link |
223 | Unique Binary Search Trees II | Medium | Link |
224 | Unique Binary Search Trees | Medium | Link |
225 | Sort Colors | Medium | Link |
226 | Subsets | Medium | Link |
227 | Remove Duplicates from Sorted List II | Medium | Link |
228 | Partition List | Medium | Link |
229 | Simplify Path | Medium | Link |
230 | Search in Rotated Sorted Array II | Medium | Link |
231 | Remove Duplicates from Sorted Array II | Medium | Link |
232 | Valid Sudoku | Medium | Link |
233 | Recover Binary Search Tree | Medium | Link |
234 | Word Search | Medium | Link |
235 | Reverse Linked List II | Medium | Link |
236 | Interleaving String | Medium | Link |
237 | Find First and Last Position Of Element in Sorted Array | Medium | Link |
238 | Min Stack | Medium | Link |
239 | Pow(x,n) | Medium | Link |
240 | Group Anagrams | Medium | Link |
241 | Rotate Image | Medium | Link |
242 | Permutations II | Medium | Link |
243 | Jump Game II | Medium | Link |
244 | Combination Sum II | Medium | Link |
245 | Multiply Strings | Medium | Link |
246 | Combination Sum | Medium | Link |
247 | Swap Nodes in Pairs | Medium | Link |
248 | Permutations | Medium | Link |
249 | Search in Rotated Sorted Array | Medium | Link |
250 | Next Permutation | Medium | Link |
251 | Divide Two Integers | Medium | Link |
252 | Find the Index of the First Occurrence in a String | Medium | Link |
253 | Delete Node in a Linked List | Medium | Link |
254 | Convert Sorted List to Binary Search Tree | Medium | Link |
255 | House Robber | Medium | Link |
256 | Maximal Square | Medium | Link |
257 | Basic Calculator II | Medium | Link |
258 | Longest Palindromic Substring | Medium | Link |
259 | Zigzag Conversion | Medium | Link |
260 | 3Sum | Medium | Link |
261 | Longest Substring without Repeating Characters | Medium | Link |
262 | Add Two Numbers | Medium | Link |
263 | Best Time to Buy and Sell Stock II | Medium | Link |
Largest Rectangle in Histogram LeetCode Solution
Number of Transactions per Visit LeetCode Solution
This Leetcode problem Number of Transactions per Visit LeetCode Solution is done in SQL. List…
Construct Binary Tree from Preorder and Inorder Traversal LeetCode Solution
Here, We see Construct Binary Tree from Preorder and Inorder Traversal LeetCode Solution. This Leetcode…
Integer to English Words LeetCode Solution
Here, We see Integer to English Words LeetCode Solution. This Leetcode problem is done in…
Employees Earning More Than Their Managers LeetCode Solution
This Leetcode problem Employees Earning More Than Their Managers LeetCode Solution is done in SQL….
Water and Jug Problem LeetCode Solution
Here, We see Water and Jug Problem LeetCode Solution. This Leetcode problem is done in…