a plan, not a list
DSA K120
All 120 problems in plan order. Filter by difficulty or status, and open any row to see the common mistake.
120 of 120 problems
- 1Best Time to Buy and Sell Stock (opens LeetCode in a new tab)Week 1 · Running minimumEasy
- Common mistake
- Starting best at a negative number instead of 0.
- 2Contains Duplicate (opens LeetCode in a new tab)Week 1 · Hash setEasy
- Common mistake
- Adding to the set before checking it.
- 3Valid Anagram (opens LeetCode in a new tab)Week 1 · Frequency countEasy
- Common mistake
- Skipping the length check first.
- 4Two Sum (opens LeetCode in a new tab)Week 1 · Hash map: value to indexEasy
- Common mistake
- Storing x before the lookup lets an element pair with itself.
- 5Maximum Subarray (opens LeetCode in a new tab)Week 1 · Kadane's algorithmMedium
- Common mistake
- Starting best at 0 breaks arrays that are all negative.
- 6Group Anagrams (opens LeetCode in a new tab)Week 1 · Map with a computed keyMedium
- Common mistake
- Using a list as a key. Convert it to a string or tuple.
- 7Top K Frequent Elements (opens LeetCode in a new tab)Week 1 · Frequency map + bucket sortMedium
- Common mistake
- Bucket array of size n instead of n+1.
- 8Longest Consecutive Sequence (opens LeetCode in a new tab)Week 1 · Hash set, find startsMedium
- Common mistake
- Counting from every number makes it O(n^2).
- 9Product of Array Except Self (opens LeetCode in a new tab)Week 1 · Prefix and suffix passesMedium
- Common mistake
- Updating the running product before using it.
- 10Subarray Sum Equals K (opens LeetCode in a new tab)Week 1 · Prefix sum + mapMedium
- Common mistake
- Forgetting the seed, or updating the map before the lookup.
- 11Valid Palindrome (opens LeetCode in a new tab)Week 2 · Two pointers from both endsEasy
- Common mistake
- Inner skip loops that forget to check l < r.
- 12Container With Most Water (opens LeetCode in a new tab)Week 2 · Two pointers, move the shorter sideMedium
- Common mistake
- Moving the taller pointer (it can never help).
- 133Sum (opens LeetCode in a new tab)Week 2 · Sort + two pointersMedium
- Common mistake
- Placing the duplicate-skipping in the wrong spot.
- 14Sort Colors (opens LeetCode in a new tab)Week 2 · Three pointers (low, mid, high)Medium
- Common mistake
- Advancing mid after a swap with high.
- 15Trapping Rain Water (opens LeetCode in a new tab)Week 2 · Two pointers with left and right maxHard
- Common mistake
- Updating the max after computing water instead of before.
- 16Rotate Image (opens LeetCode in a new tab)Week 2 · In-place matrix index mathMedium
- Common mistake
- Looping j over the whole row in the transpose, which undoes the swaps.
- 17Longest Substring Without Repeating Characters (opens LeetCode in a new tab)Week 2 · Sliding window + setMedium
- Common mistake
- Not removing characters from the set as the window shrinks.
- 18Longest Repeating Character Replacement (opens LeetCode in a new tab)Week 2 · Window with a validity ruleMedium
- Common mistake
- Trying to lower max_freq when shrinking. It does not need to go down.
- 19Permutation in String (opens LeetCode in a new tab)Week 2 · Fixed-size window + countsMedium
- Common mistake
- Off-by-one when building the first window.
- 20Minimum Window Substring (opens LeetCode in a new tab)Week 2 · Variable window with need and haveHard
- Common mistake
- Updating the satisfied count at the wrong moment (only when a count reaches its need).
- 21Binary Search (opens LeetCode in a new tab)Week 3 · Classic templateEasy
- Common mistake
- Setting l = mid, which can loop forever.
- 22Search a 2D Matrix (opens LeetCode in a new tab)Week 3 · Binary search on a flattened matrixMedium
- Common mistake
- Dividing by rows instead of cols.
- 23Find Minimum in Rotated Sorted Array (opens LeetCode in a new tab)Week 3 · Binary search on a rotated arrayMedium
- Common mistake
- Using r = mid - 1, which can skip the minimum.
- 24Search in Rotated Sorted Array (opens LeetCode in a new tab)Week 3 · Find the sorted halfMedium
- Common mistake
- Using < instead of <= in the sorted-half test.
- 25Find Peak Element (opens LeetCode in a new tab)Week 3 · Binary search on the slopeMedium
- Common mistake
- Reading a[mid+1] when mid could be the last index (use l < r).
- 26Koko Eating Bananas (opens LeetCode in a new tab)Week 3 · Binary search on the answerMedium
- Common mistake
- Float division. Use (p + k - 1) // k.
- 27Time Based Key-Value Store (opens LeetCode in a new tab)Week 3 · Binary search inside a design problemMedium
- Common mistake
- Returning the wrong value when no time is <= t. Return an empty string.
- 28Single Number (opens LeetCode in a new tab)Week 3 · XOR cancellationEasy
- Common mistake
- There is little to get wrong in the code. Be able to explain why x ^ x = 0.
- 29Number of 1 Bits (opens LeetCode in a new tab)Week 3 · Clear the lowest set bitEasy
- Common mistake
- Negative numbers in some languages. Mask to 32 bits.
- 30Sum of Two Integers (opens LeetCode in a new tab)Week 3 · Add with XOR and carryMedium
- Common mistake
- Python only: mask to 32 bits because integers never overflow.
- Showing 30 of 120