knaxuslearn · build · ship

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

  1. 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.
  2. 2Contains Duplicate (opens LeetCode in a new tab)Week 1 · Hash setEasy
    Common mistake
    Adding to the set before checking it.
  3. 3Valid Anagram (opens LeetCode in a new tab)Week 1 · Frequency countEasy
    Common mistake
    Skipping the length check first.
  4. 4Two Sum (opens LeetCode in a new tab)Week 1 · Hash map: value to indexEasycore
    Common mistake
    Storing x before the lookup lets an element pair with itself.
  5. 5Maximum Subarray (opens LeetCode in a new tab)Week 1 · Kadane's algorithmMediumcore
    Common mistake
    Starting best at 0 breaks arrays that are all negative.
  6. 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.
  7. 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.
  8. 8Longest Consecutive Sequence (opens LeetCode in a new tab)Week 1 · Hash set, find startsMediumcore
    Common mistake
    Counting from every number makes it O(n^2).
  9. 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.
  10. 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.
  11. 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.
  12. 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).
  13. 133Sum (opens LeetCode in a new tab)Week 2 · Sort + two pointersMediumcore
    Common mistake
    Placing the duplicate-skipping in the wrong spot.
  14. 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.
  15. 15Trapping Rain Water (opens LeetCode in a new tab)Week 2 · Two pointers with left and right maxHardcore
    Common mistake
    Updating the max after computing water instead of before.
  16. 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.
  17. 17Longest Substring Without Repeating Characters (opens LeetCode in a new tab)Week 2 · Sliding window + setMediumcore
    Common mistake
    Not removing characters from the set as the window shrinks.
  18. 18Longest Repeating Character Replacement (opens LeetCode in a new tab)Week 2 · Window with a validity ruleMediumcore
    Common mistake
    Trying to lower max_freq when shrinking. It does not need to go down.
  19. 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.
  20. 20Minimum Window Substring (opens LeetCode in a new tab)Week 2 · Variable window with need and haveHardcore
    Common mistake
    Updating the satisfied count at the wrong moment (only when a count reaches its need).
  21. 21Binary Search (opens LeetCode in a new tab)Week 3 · Classic templateEasy
    Common mistake
    Setting l = mid, which can loop forever.
  22. 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.
  23. 23Find Minimum in Rotated Sorted Array (opens LeetCode in a new tab)Week 3 · Binary search on a rotated arrayMediumcore
    Common mistake
    Using r = mid - 1, which can skip the minimum.
  24. 24Search in Rotated Sorted Array (opens LeetCode in a new tab)Week 3 · Find the sorted halfMediumcore
    Common mistake
    Using < instead of <= in the sorted-half test.
  25. 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).
  26. 26Koko Eating Bananas (opens LeetCode in a new tab)Week 3 · Binary search on the answerMediumcore
    Common mistake
    Float division. Use (p + k - 1) // k.
  27. 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.
  28. 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.
  29. 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.
  30. 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.
  31. Showing 30 of 120