Neetcode 150 is a curated list of 150 LeetCode problems designed to cover all topics in data structures. It is an invaluable resource to study for LeetCode-style interviews you might enounter at FAANG and other big tech companies. There are several categories of questions and inside each category are easy, medium, and hard questions.
Creator's original repository and website.
Below is a list of my solutions for all the problems in C++, Python and Rust.
To contribute, see here.
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
217 | Easy | Contains Duplicate | C++ • Python • Rust |
242 | Easy | Valid Anagram | C++ • Python • Rust |
1 | Easy | Two Sum | C++ • Python • Rust |
49 | Medium | Group Anagrams | C++ • Python • Rust |
347 | Medium | Top K Frequent Elements | C++ • Python • Rust |
238 | Medium | Product of Array Except Self | C++ • Python • Rust |
36 | Medium | Valid Sudoku | C++ • Python • Rust |
271 | Medium | Encode and Decode Strings | C++ • Python • Rust |
128 | Medium | Longest Consecutive Sequence | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
125 | Easy | Valid Palindrome | C++ • Python • Rust |
167 | Medium | Two Sum II | C++ • Python • Rust |
15 | Medium | 3Sum | C++ • Python • Rust |
11 | Medium | Container with Most Water | C++ • Python • Rust |
42 | Hard | Trapping Rain Water | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
121 | Easy | Best Time to Buy & Sell Stock | C++ • Python • Rust |
3 | Medium | Longest Substring Without Repeating Characters | C++ • Python • Rust |
424 | Medium | Longest Repeating Character Replacement | C++ • Python • Rust |
567 | Medium | Permutation in String | C++ • Python • Rust |
76 | Hard | Minimum Window Substring | C++ • Python • Rust |
239 | Hard | Sliding Window Maximum | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
20 | Easy | Valid Parentheses | C++ • Python • Rust |
155 | Medium | Min Stack | C++ • Python • Rust |
150 | Medium | Evaluate Reverse Polish Notation | C++ • Python • Rust |
22 | Medium | Generate Parentheses | C++ • Python • Rust |
739 | Medium | Daily Temperatures | C++ • Python • Rust |
853 | Medium | Car Fleet | C++ • Python • Rust |
84 | Hard | Largest Rectangle in Histogram | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
704 | Easy | Binary Search | C++ • Python • Rust |
74 | Medium | Search a 2D Matrix | C++ • Python • Rust |
875 | Medium | Koko Eating Bananas | C++ • Python • Rust |
33 | Medium | Search in Rotated Sorted Array | C++ • Python • Rust |
153 | Medium | Find Minimum in Rotated Sorted Array | C++ • Python • Rust |
981 | Medium | Time Based Key-Value Store | C++ • Python • Rust |
4 | Hard | Median of Two Sorted Arrays | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
206 | Easy | Reverse Linked List | C++ • Python • Rust |
21 | Easy | Merge Two Sorted Lists | C++ • Python • Rust |
143 | Medium | Reorder List | C++ • Python • Rust |
19 | Medium | Remove Nth Node From End of List | C++ • Python • Rust |
141 | Easy | Copy List with Random Pointer | C++ • Python • Rust |
2 | Medium | Add Two Numbers | C++ • Python • Rust |
141 | Easy | Linked List Cycle | C++ • Python • Rust |
287 | Medium | Find the Duplicate Number | C++ • Python • Rust |
146 | Medium | LRU Cache | C++ • Python • Rust |
23 | Hard | Merge k Sorted Lists | C++ • Python • Rust |
25 | Hard | Reverse Nodes in k-Group | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
226 | Easy | Invert Binary Tree | C++ • Python • Rust |
104 | Easy | Maximum Depth of Binary Tree | C++ • Python • Rust |
543 | Easy | Diameter of Binary Tree | C++ • Python • Rust |
110 | Easy | Balanced Binary Tree | C++ • Python • Rust |
100 | Easy | Same Tree | C++ • Python • Rust |
572 | Easy | Subtree Of Another Tree | C++ • Python • Rust |
235 | Medium | Lowest Common Ancestor Of A Binary Search Tree | C++ • Python • Rust |
102 | Medium | Binary Tree Level Order Traversal | C++ • Python • Rust |
199 | Medium | Binary Tree Right Side View | C++ • Python • Rust |
1448 | Medium | Count Good Nodes in Binary Tree | C++ • Python • Rust |
98 | Medium | Validate Binary Search Tree | C++ • Python • Rust |
230 | Medium | Kth Smallest Element in a BST | C++ • Python • Rust |
105 | Medium | Construct Binary Tree from Preorder and Inorder Traversal | C++ • Python • Rust |
124 | Hard | Binary Tree Maximum Path Sum | C++ • Python • Rust |
297 | Hard | Serialize and Deserialize Binary Tree | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
208 | Medium | Implement Trie (Prefix Tree) | C++ • Python • Rust |
211 | Medium | Design Add and Search Words Data Structure | C++ • Python • Rust |
212 | Hard | Word Search II | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
703 | Easy | Kth Largest Element in a Stream | C++ • Python • Rust |
1046 | Easy | Last Stone Weight | C++ • Python • Rust |
973 | Medium | K Closest Points to Origin | C++ • Python • Rust |
215 | Medium | Kth Largest Element in an Array | C++ • Python • Rust |
621 | Medium | Task Scheduler | C++ • Python • Rust |
355 | Medium | Design Twitter | C++ • Python • Rust |
295 | Hard | Find Median from Data Stream | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
78 | Medium | Subsets | C++ • Python • Rust |
39 | Medium | Combination Sum | C++ • Python • Rust |
46 | Medium | Permutations | C++ • Python • Rust |
90 | Medium | Subsets II | C++ • Python • Rust |
40 | Medium | Combination Sum II | C++ • Python • Rust |
79 | Medium | Word Search | C++ • Python • Rust |
131 | Medium | Palindrome Partitioning | C++ • Python • Rust |
17 | Medium | Letter Combinations of a Phone Number | C++ • Python • Rust |
51 | Hard | N-Queens | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
200 | Medium | Number of Islands | C++ • Python • Rust |
133 | Medium | Clone Graph | C++ • Python • Rust |
695 | Medium | Max Area of Island | C++ • Python • Rust |
417 | Medium | Pacific Atlantic Water Flow | C++ • Python • Rust |
130 | Medium | Surrounded Regions | C++ • Python • Rust |
994 | Medium | Rotting Oranges | C++ • Python • Rust |
286 | Medium | Walls and Gates | C++ • Python • Rust |
207 | Medium | Course Schedule | C++ • Python • Rust |
210 | Medium | Course Schedule II | C++ • Python • Rust |
684 | Medium | Redundant Connection | C++ • Python • Rust |
323 | Medium | Number of Connected Components In An Undirected Graph | C++ • Python • Rust |
261 | Medium | Graph Valid Tree | C++ • Python • Rust |
127 | Hard | Word Ladder | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
332 | Hard | Reconstruct Itinerary | C++ • Python • Rust |
1584 | Medium | Min Cost to Connect All Points | C++ • Python • Rust |
743 | Medium | Network Delay Time | C++ • Python • Rust |
778 | Hard | Swim in Rising Water | C++ • Python • Rust |
269 | Hard | Alien Dictionary | C++ • Python • Rust |
787 | Medium | Cheapest Flights Within K Stops | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
70 | Easy | Climbing Stairs | C++ • Python • Rust |
746 | Easy | Min Cost Climbing Stairs | C++ • Python • Rust |
198 | Medium | House Robber | C++ • Python • Rust |
213 | Medium | House Robber II | C++ • Python • Rust |
5 | Medium | Longest Palindromic Substring | C++ • Python • Rust |
647 | Medium | Palindromic Substrings | C++ • Python • Rust |
91 | Medium | Decode Ways | C++ • Python • Rust |
322 | Medium | Coin Change | C++ • Python • Rust |
152 | Medium | Maximum Product Subarray | C++ • Python • Rust |
139 | Medium | Word Break | C++ • Python • Rust |
300 | Medium | Longest Increasing Subsequence | C++ • Python • Rust |
416 | Medium | Partition Equal Subset Sum | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
62 | Medium | Unique Paths | C++ • Python • Rust |
1143 | Medium | Longest Common Subsequence | C++ • Python • Rust |
309 | Medium | Best Time to Buy and Sell Stock with Cooldown | C++ • Python • Rust |
518 | Medium | Coin Change II | C++ • Python • Rust |
494 | Medium | Target Sum | C++ • Python • Rust |
97 | Medium | Interleaving String | C++ • Python • Rust |
329 | Hard | Longest Increasing Path in a Matrix | C++ • Python • Rust |
115 | Hard | Distinct Subsequences | C++ • Python • Rust |
72 | Hard | Edit Distance | C++ • Python • Rust |
312 | Hard | Burst Balloons | C++ • Python • Rust |
10 | Hard | Regular Expression Matching | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
53 | Medium | Maximum Subarray | C++ • Python • Rust |
55 | Medium | Jump Game | C++ • Python • Rust |
45 | Medium | Jump Game II | C++ • Python • Rust |
134 | Medium | Gas Station | C++ • Python • Rust |
846 | Medium | Hand of Straights | C++ • Python • Rust |
1899 | Medium | Merge Triplets to Form Target Triplet | C++ • Python • Rust |
763 | Medium | Partition Labels | C++ • Python • Rust |
678 | Medium | Valid Parenthesis String | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
57 | Medium | Insert Interval | C++ • Python • Rust |
56 | Medium | Merge Intervals | C++ • Python • Rust |
435 | Medium | Non-overlapping Intervals | C++ • Python • Rust |
252 | Easy | Meeting Rooms | C++ • Python • Rust |
253 | Medium | Meeting Rooms II | C++ • Python • Rust |
1851 | Hard | Minimum Interval to Include Each Query | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
48 | Medium | Rotate Image | C++ • Python • Rust |
54 | Medium | Spiral Matrix | C++ • Python • Rust |
73 | Medium | Set Matrix Zeroes | C++ • Python • Rust |
202 | Easy | Happy Number | C++ • Python • Rust |
66 | Easy | Plus One | C++ • Python • Rust |
50 | Medium | Pow(x, n) | C++ • Python • Rust |
43 | Medium | Multiply Strings | C++ • Python • Rust |
2013 | Medium | Detect Squares | C++ • Python • Rust |
LeetCode ID | Difficulty | Problem | Solution |
---|---|---|---|
136 | Easy | Single Number | C++ • Python • Rust |
191 | Easy | Number of 1 Bits | C++ • Python • Rust |
338 | Easy | Counting Bits | C++ • Python • Rust |
190 | Easy | Reverse Bits | C++ • Python • Rust |
268 | Easy | Missing Number | C++ • Python • Rust |
371 | Medium | Sum of Two Integers | C++ • Python • Rust |
7 | Medium | Reverse Integer | C++ • Python • Rust |
If you have a better solution, feel free to open a PR. Add a small summary of your solution with space and time complexities.
- Make sure your code passes all the test cases on LeetCode for the problem it solves.
- Write clean code that is easy to understand.
- Give your PR a succinct and accurate title.