Skip to main content

Patterns-First 50

Stop solving each problem from scratch. Recognize the pattern in the first thirty seconds and execute the template.

By Alex Chen, Founder, InterviewChamp.AI · 50 problems · ~60h · difficulty: mixed · Last verified

  1. Day 1Two Sum(arrays)

    Two Pointers: hash-map variant of the two-pointer mental model — looking for a complementary value as you scan.

  2. Day 2Valid Palindrome(strings)

    Two Pointers: classic converging pointers from both ends. The shape every string-checking problem reduces to.

  3. Two Pointers: shrink from the side with the shorter wall. The 'why this side?' question is the whole interview.

  4. Day 43Sum(arrays)

    Two Pointers: fix one anchor, then collapse two pointers on the remainder. The bridge from O(n^3) to O(n^2).

  5. Sliding Window: variable-width window with a set. Master the 'shrink left until valid' loop before all other window problems.

  6. Sliding Window: fixed-width window with a frequency counter. Different shape, same window discipline.

  7. Day 7Maximum Subarray(dp-1d)

    Sliding Window (Kadane's variant): expand when the running sum helps, reset when it hurts. The simplest dynamic window.

  8. Day 8Contains Duplicate(hash-tables)

    Hash Map: set-membership in O(1). The simplest possible application — practice narrating space-for-time.

  9. Day 9Valid Anagram(strings)

    Hash Map: frequency-counter template. The same template you'll reuse in ten more problems this month.

  10. Day 10Group Anagrams(strings)

    Hash Map: keyed bucketing. Build a canonical key from the input, group by key. Trade-off between sorted-key and count-tuple is the interview probe.

  11. Day 11Top K Frequent Elements(hash-tables)

    Hash Map + bucket sort: count, then bucket by frequency. Beats the heap solution at O(n).

  12. Day 12Subarray Sum Equals K(hash-tables)

    Hash Map: prefix-sum + complement lookup. The 'two-sum on prefix sums' trick — unlocks a dozen subarray problems.

  13. Day 13Longest Consecutive Sequence(hash-tables)

    Hash Map: O(n) via 'only start counting at sequence heads'. The trick is the guard, not the data structure.

  14. Day 14Binary Search(binary-search)

    Binary Search: the canonical lo/hi/mid template. Drill until the off-by-one boundaries are reflex.

  15. Binary Search: compare mid to RIGHT instead of target. First problem that breaks the 'binary search needs a target' frame.

  16. Day 16Search in Rotated Sorted Array(binary-search)

    Binary Search: decide which half is sorted, check if target lives there, recurse. The four branches are fiddly — write them out.

  17. Day 17Koko Eating Bananas(binary-search)

    Binary Search: search on the ANSWER, not an index. Once you see it once, you spot it in capacity-to-ship and split-array-largest-sum.

  18. BFS: queue + snapshot size per level. The canonical level-by-level template — reused in graphs verbatim.

  19. Day 19Number of Islands(graphs)

    BFS (or DFS): grid traversal with visited marking. The flood-fill template that powers every 'count regions' problem.

  20. Day 20Clone Graph(graphs)

    BFS: queue + hash map (old -> new) acting as both visited set AND clone lookup. Two jobs, one data structure.

  21. Day 21Word Ladder(graphs)

    BFS: shortest path in an implicit graph. Build neighbors on the fly via wildcard patterns — the trick that turns O(n^2) into O(n).

  22. DFS: recursive height computation. The simplest recursion on trees — base = null, recurse = children.

  23. Day 23Course Schedule(graphs)

    DFS: cycle detection in a directed graph via three-color marking. The shape of every dependency-resolution interview question.

  24. DFS: reverse the question — instead of 'which cells can flow out', ask 'which cells can the ocean reach inward'. Two DFS, then intersect.

  25. DFS: pass (lo, hi) bounds down the recursion. The shortcut of comparing each node to parent only is the WRONG answer — interviewers test for it.

  26. Day 26Subsets(bit-manipulation)

    Backtracking: include/exclude tree. The simplest backtrack — every other backtracking problem is a richer version of this choice.

  27. Day 27Permutations(recursion)

    Backtracking: swap-in-place to generate every ordering. The 'used set' alternative is also valid — defend whichever you pick.

  28. Day 28Combination Sum(recursion)

    Backtracking: recurse with a start-index to forbid duplicates. The start-index trick is the only difference from permutations.

  29. Day 29Word Search(recursion)

    Backtracking: grid DFS with mark-and-unmark. The unmark on the way back up is the part beginners forget.

  30. Day 30N-Queens(recursion)

    Backtracking: column + diagonal sets pruned per row. The hard version: prove your pruning is correct, don't just trust the recursion.

  31. Day 31Jump Game(dp-1d)

    Greedy: maintain the farthest reachable index. The DP exists but greedy is the answer — name the swap explicitly.

  32. Day 32Jump Game II(dp-1d)

    Greedy: BFS-like layers — expand the 'current jump' window until it closes, then bump the count.

  33. Day 33Gas Station(dp-1d)

    Greedy: if total gas >= total cost, an answer exists; restart from i+1 whenever the tank goes negative. Two passes collapse to one.

  34. Day 34Task Scheduler(heaps)

    Greedy: cooldown math — most-frequent task sets the floor. The formula derivation is what interviewers want you to walk through.

  35. Day 35Climbing Stairs(dynamic-programming)

    1D DP: f(n) = f(n-1) + f(n-2). The simplest possible recurrence — drill the bottom-up form before any harder DP.

  36. Day 36House Robber(dynamic-programming)

    1D DP: f(i) = max(f(i-1), f(i-2) + nums[i]). The 'rob or skip' decision is the substrate for every linear DP.

  37. Day 37Coin Change(dynamic-programming)

    1D DP: unbounded knapsack. dp[amount] = min over coins of dp[amount - coin] + 1. Practice narrating WHY it's not greedy.

  38. Day 38Longest Increasing Subsequence(dynamic-programming)

    1D DP: O(n^2) baseline first. Save the O(n log n) patience-sort trick for the follow-up.

  39. Day 39Word Break(dynamic-programming)

    1D DP: dp[i] = can-we-segment prefix of length i. Each position checks 'does some valid word end here AND was the prefix before it segmentable?'

  40. 1D DP (knapsack flavor): can we hit target = sum/2? The 0/1 knapsack reduction is the whole interview signal.

  41. Day 41Unique Paths(dynamic-programming)

    2D DP: grid count — dp[i][j] = dp[i-1][j] + dp[i][j-1]. The simplest 2D recurrence — burn the bottom-up form into reflex.

  42. Day 42Minimum Path Sum(dp-2d)

    2D DP: same recurrence as unique-paths, swap count for min(). Practice articulating which DP transitions transfer between problems.

  43. 2D DP (or expand-around-center): the DP fills a is_palindrome[i][j] table. Be ready to defend either approach — interviewers ask why one beats the other.

  44. 2D DP on intervals. dp[i][j] = longest palindrome in s[i..j]. The classic 'expand the interval' DP shape.

  45. Day 45Maximal Square(dp-2d)

    2D DP: dp[i][j] = side-length of largest square ending here = 1 + min of three neighbors. Beautiful recurrence — derive it on the spot.

  46. Day 46Last Stone Weight(heaps)

    Heap: max-heap, pop two, push the difference. The simplest possible heap problem — train the 'do I need to keep the K largest?' instinct.

  47. Heap: min-heap of size k. Trade-off vs quickselect is the whole conversation — be ready to defend both choices out loud.

  48. Heap: max-heap of size k, kicked by distance. Same skeleton as kth-largest with a custom comparator.

  49. Heap: two heaps (max-heap of lower half, min-heap of upper half), kept balanced. The two-heap pattern unlocks sliding-window median too.

  50. Day 50Word Search II(recursion)

    Trie + Backtracking: build a Trie of words once, then DFS the board with the Trie as a multi-target pruner. Capstone — combines two patterns.

Ready to drill these live?

Get the AI copilot in your ear during real interviews. Real-time transcription. Streaming answers. Post-call scorecard.

Download the desktop app →