Skip to content

Latest commit

 

History

History
260 lines (216 loc) · 92.1 KB

README.md

File metadata and controls

260 lines (216 loc) · 92.1 KB

What is NeetCode 150?

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.

Arrays & Hashing

LeetCode ID Difficulty Problem Solution
217 Easy Contains Duplicate C++PythonRust
242 Easy Valid Anagram C++PythonRust
1 Easy Two Sum C++PythonRust
49 Medium Group Anagrams C++PythonRust
347 Medium Top K Frequent Elements C++PythonRust
238 Medium Product of Array Except Self C++PythonRust
36 Medium Valid Sudoku C++PythonRust
271 Medium Encode and Decode Strings C++PythonRust
128 Medium Longest Consecutive Sequence C++PythonRust

Two Pointers

LeetCode ID Difficulty Problem Solution
125 Easy Valid Palindrome C++PythonRust
167 Medium Two Sum II C++PythonRust
15 Medium 3Sum C++PythonRust
11 Medium Container with Most Water C++PythonRust
42 Hard Trapping Rain Water C++PythonRust

Sliding Window

LeetCode ID Difficulty Problem Solution
121 Easy Best Time to Buy & Sell Stock C++PythonRust
3 Medium Longest Substring Without Repeating Characters C++PythonRust
424 Medium Longest Repeating Character Replacement C++PythonRust
567 Medium Permutation in String C++PythonRust
76 Hard Minimum Window Substring C++PythonRust
239 Hard Sliding Window Maximum C++PythonRust

Stack

LeetCode ID Difficulty Problem Solution
20 Easy Valid Parentheses C++PythonRust
155 Medium Min Stack C++PythonRust
150 Medium Evaluate Reverse Polish Notation C++PythonRust
22 Medium Generate Parentheses C++PythonRust
739 Medium Daily Temperatures C++PythonRust
853 Medium Car Fleet C++PythonRust
84 Hard Largest Rectangle in Histogram C++PythonRust

Binary Search

LeetCode ID Difficulty Problem Solution
704 Easy Binary Search C++PythonRust
74 Medium Search a 2D Matrix C++PythonRust
875 Medium Koko Eating Bananas C++PythonRust
33 Medium Search in Rotated Sorted Array C++PythonRust
153 Medium Find Minimum in Rotated Sorted Array C++PythonRust
981 Medium Time Based Key-Value Store C++PythonRust
4 Hard Median of Two Sorted Arrays C++PythonRust

Linked List

LeetCode ID Difficulty Problem Solution
206 Easy Reverse Linked List C++PythonRust
21 Easy Merge Two Sorted Lists C++PythonRust
143 Medium Reorder List C++PythonRust
19 Medium Remove Nth Node From End of List C++PythonRust
141 Easy Copy List with Random Pointer C++PythonRust
2 Medium Add Two Numbers C++PythonRust
141 Easy Linked List Cycle C++PythonRust
287 Medium Find the Duplicate Number C++PythonRust
146 Medium LRU Cache C++PythonRust
23 Hard Merge k Sorted Lists C++PythonRust
25 Hard Reverse Nodes in k-Group C++PythonRust

Trees

LeetCode ID Difficulty Problem Solution
226 Easy Invert Binary Tree C++PythonRust
104 Easy Maximum Depth of Binary Tree C++PythonRust
543 Easy Diameter of Binary Tree C++PythonRust
110 Easy Balanced Binary Tree C++PythonRust
100 Easy Same Tree C++PythonRust
572 Easy Subtree Of Another Tree C++PythonRust
235 Medium Lowest Common Ancestor Of A Binary Search Tree C++PythonRust
102 Medium Binary Tree Level Order Traversal C++PythonRust
199 Medium Binary Tree Right Side View C++PythonRust
1448 Medium Count Good Nodes in Binary Tree C++PythonRust
98 Medium Validate Binary Search Tree C++PythonRust
230 Medium Kth Smallest Element in a BST C++PythonRust
105 Medium Construct Binary Tree from Preorder and Inorder Traversal C++PythonRust
124 Hard Binary Tree Maximum Path Sum C++PythonRust
297 Hard Serialize and Deserialize Binary Tree C++PythonRust

Tries

LeetCode ID Difficulty Problem Solution
208 Medium Implement Trie (Prefix Tree) C++PythonRust
211 Medium Design Add and Search Words Data Structure C++PythonRust
212 Hard Word Search II C++PythonRust

Heap / Priority Queue

LeetCode ID Difficulty Problem Solution
703 Easy Kth Largest Element in a Stream C++PythonRust
1046 Easy Last Stone Weight C++PythonRust
973 Medium K Closest Points to Origin C++PythonRust
215 Medium Kth Largest Element in an Array C++PythonRust
621 Medium Task Scheduler C++PythonRust
355 Medium Design Twitter C++PythonRust
295 Hard Find Median from Data Stream C++PythonRust

Backtracking

LeetCode ID Difficulty Problem Solution
78 Medium Subsets C++PythonRust
39 Medium Combination Sum C++PythonRust
46 Medium Permutations C++PythonRust
90 Medium Subsets II C++PythonRust
40 Medium Combination Sum II C++PythonRust
79 Medium Word Search C++PythonRust
131 Medium Palindrome Partitioning C++PythonRust
17 Medium Letter Combinations of a Phone Number C++PythonRust
51 Hard N-Queens C++PythonRust

Graphs

LeetCode ID Difficulty Problem Solution
200 Medium Number of Islands C++PythonRust
133 Medium Clone Graph C++PythonRust
695 Medium Max Area of Island C++PythonRust
417 Medium Pacific Atlantic Water Flow C++PythonRust
130 Medium Surrounded Regions C++PythonRust
994 Medium Rotting Oranges C++PythonRust
286 Medium Walls and Gates C++PythonRust
207 Medium Course Schedule C++PythonRust
210 Medium Course Schedule II C++PythonRust
684 Medium Redundant Connection C++PythonRust
323 Medium Number of Connected Components In An Undirected Graph C++PythonRust
261 Medium Graph Valid Tree C++PythonRust
127 Hard Word Ladder C++PythonRust

Advanced Graphs

LeetCode ID Difficulty Problem Solution
332 Hard Reconstruct Itinerary C++PythonRust
1584 Medium Min Cost to Connect All Points C++PythonRust
743 Medium Network Delay Time C++PythonRust
778 Hard Swim in Rising Water C++PythonRust
269 Hard Alien Dictionary C++PythonRust
787 Medium Cheapest Flights Within K Stops C++PythonRust

1-D Dynamic Programming

LeetCode ID Difficulty Problem Solution
70 Easy Climbing Stairs C++PythonRust
746 Easy Min Cost Climbing Stairs C++PythonRust
198 Medium House Robber C++PythonRust
213 Medium House Robber II C++PythonRust
5 Medium Longest Palindromic Substring C++PythonRust
647 Medium Palindromic Substrings C++PythonRust
91 Medium Decode Ways C++PythonRust
322 Medium Coin Change C++PythonRust
152 Medium Maximum Product Subarray C++PythonRust
139 Medium Word Break C++PythonRust
300 Medium Longest Increasing Subsequence C++PythonRust
416 Medium Partition Equal Subset Sum C++PythonRust

2-D Dynamic Programing

LeetCode ID Difficulty Problem Solution
62 Medium Unique Paths C++PythonRust
1143 Medium Longest Common Subsequence C++PythonRust
309 Medium Best Time to Buy and Sell Stock with Cooldown C++PythonRust
518 Medium Coin Change II C++PythonRust
494 Medium Target Sum C++PythonRust
97 Medium Interleaving String C++PythonRust
329 Hard Longest Increasing Path in a Matrix C++PythonRust
115 Hard Distinct Subsequences C++PythonRust
72 Hard Edit Distance C++PythonRust
312 Hard Burst Balloons C++PythonRust
10 Hard Regular Expression Matching C++PythonRust

Greedy

LeetCode ID Difficulty Problem Solution
53 Medium Maximum Subarray C++PythonRust
55 Medium Jump Game C++PythonRust
45 Medium Jump Game II C++PythonRust
134 Medium Gas Station C++PythonRust
846 Medium Hand of Straights C++PythonRust
1899 Medium Merge Triplets to Form Target Triplet C++PythonRust
763 Medium Partition Labels C++PythonRust
678 Medium Valid Parenthesis String C++PythonRust

Intervals

LeetCode ID Difficulty Problem Solution
57 Medium Insert Interval C++PythonRust
56 Medium Merge Intervals C++PythonRust
435 Medium Non-overlapping Intervals C++PythonRust
252 Easy Meeting Rooms C++PythonRust
253 Medium Meeting Rooms II C++PythonRust
1851 Hard Minimum Interval to Include Each Query C++PythonRust

Math & Geometry

LeetCode ID Difficulty Problem Solution
48 Medium Rotate Image C++PythonRust
54 Medium Spiral Matrix C++PythonRust
73 Medium Set Matrix Zeroes C++PythonRust
202 Easy Happy Number C++PythonRust
66 Easy Plus One C++PythonRust
50 Medium Pow(x, n) C++PythonRust
43 Medium Multiply Strings C++PythonRust
2013 Medium Detect Squares C++PythonRust

Bit Manipulation

LeetCode ID Difficulty Problem Solution
136 Easy Single Number C++PythonRust
191 Easy Number of 1 Bits C++PythonRust
338 Easy Counting Bits C++PythonRust
190 Easy Reverse Bits C++PythonRust
268 Easy Missing Number C++PythonRust
371 Medium Sum of Two Integers C++PythonRust
7 Medium Reverse Integer C++PythonRust

Contributing

If you have a better solution, feel free to open a PR. Add a small summary of your solution with space and time complexities.

Guidelines

  • 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.