DSA Patterns
Technical interviews test the same patterns over and over. Learn these 33and you'll recognize what a problem is asking before you write a single line of code.
Not sure which pattern a problem needs?
The cheat sheet: match the clue words in any problem to the right pattern.
Backtracking
Build the solution one choice at a time. Undo it when it doesn't work out.
9 problemsLearn →Binary Search
Cut the search space in half every step. O(log n) is surprisingly fast.
8 problemsLearn →Bit Manipulation
XOR cancels pairs. AND checks bits. Shifts multiply and divide by two.
7 problemsLearn →Cyclic Sort
Every number belongs at one specific index. Put it there.
3 problemsLearn →Divide and Conquer
Split the problem in half, solve each half, combine the results.
2 problemsLearn →Dynamic Programming
Define the subproblem. Write the recurrence. Fill the table. Read the answer.
14 problemsLearn →Fast & Slow Pointers
Two pointers, different speeds. One laps the other if the path loops.
4 problemsLearn →Frequency Map
Count once. Compare counts. Avoid sorting entirely.
6 problemsLearn →Graph Traversal
Mark what you've visited. Start over for each component. Follow every edge once.
8 problemsLearn →Greedy
Make the best choice right now and never look back.
8 problemsLearn →Hash Map
Stop scanning backward. Store what you've seen and look it up in one step.
5 problemsLearn →Heap / Priority Queue
Always have instant access to the best remaining option. No re-sorting needed.
4 problemsLearn →Intervals
Sort by start. Compare ends. Merge or commit with one condition.
2 problemsLearn →K-way Merge
Use a min-heap to always pull the smallest element from K sorted sources.
2 problemsLearn →Kadane's Algorithm
Extend the streak if it helps. Drop it if it hurts. Track the best you've seen.
4 problemsLearn →Linked List
No indexes. No jumping. Follow the chain and rewire it carefully.
7 problemsLearn →Matrix Traversal
Treat every grid cell as a node. Explore its four neighbors.
7 problemsLearn →Memoization
Cache what you've already computed. Never solve the same subproblem twice.
4 problemsLearn →Monotonic Queue
Maintain an ordered deque so the window's max or min is always at the front.
4 problemsLearn →Monotonic Stack
Keep the stack ordered. When that order breaks, you have your answer.
5 problemsLearn →Prefix Sum
Precompute the cumulative totals once. Answer any range query in constant time.
5 problemsLearn →Recursion
Solve the small version of the problem. Trust the function to handle the rest.
4 problemsLearn →Set
Stop scanning the whole array. Remember what you've seen.
6 problemsLearn →Sliding Window
Slide a range across the input. Don't restart from scratch every time.
7 problemsLearn →Sorting Algorithms
Put things in order so every other pattern becomes possible.
3 problemsLearn →Stack
The most recent unresolved item is always on top. Use that.
10 problemsLearn →Topological Sort
Order the dependencies before the things that depend on them.
3 problemsLearn →Tracking Minimum
Remember the best opportunity you've passed. Don't rescan to find it.
2 problemsLearn →Tree Traversal
Most binary tree problems are just: visit every node and do something at each one.
11 problemsLearn →Trie
Search any prefix in O(m). No matter how many words you've stored.
2 problemsLearn →Two Heaps
Keep two heaps balanced. The tops give you the median at every step.
3 problemsLearn →Two Pointers
Compare from both ends. Eliminate half the work at every step.
8 problemsLearn →Union Find
Group elements into components. Merge groups in near-constant time.
5 problemsLearn →
Start practicing these patterns
150 guided problems across 33 patterns. Five are free, no account needed. Each one teaches a transferable pattern with guided hints, not spoilers.