DSA Patterns
Technical interviews test the same patterns over and over. Learn these 18 and you'll recognize what a problem is asking before you write a single line of code.
Hash Map
Stop scanning backward. Store what you've seen and look it up in one step.
5 problemsLearn →Set
Stop scanning the whole array. Remember what you've seen.
6 problemsLearn →Frequency Map
Count once. Compare counts. Avoid sorting entirely.
6 problemsLearn →Two Pointers
Compare from both ends. Eliminate half the work at every step.
6 problemsLearn →Sliding Window
Slide a range across the input. Don't restart from scratch every time.
5 problemsLearn →Stack
The most recent unresolved item is always on top. Use that.
6 problemsLearn →Binary Search
Cut the search space in half every step. O(log n) is surprisingly fast.
6 problemsLearn →Linked List
No indexes. No jumping. Follow the chain and rewire it carefully.
5 problemsLearn →Kadane's Algorithm
Extend the streak if it helps. Drop it if it hurts. Track the best you've seen.
4 problemsLearn →Tree Traversal
Most binary tree problems are just: visit every node and do something at each one.
5 problemsLearn →Tracking Minimum
Remember the best opportunity you've passed. Don't rescan to find it.
3 problemsLearn →Prefix Sum
Precompute the cumulative totals once. Answer any range query in constant time.
5 problemsLearn →Dynamic Programming
Define the subproblem. Write the recurrence. Fill the table. Read the answer.
5 problemsLearn →Intervals
Sort by start. Compare ends. Merge or commit with one condition.
5 problemsLearn →Monotonic Stack
Keep the stack ordered. When that order breaks, you have your answer.
5 problemsLearn →Heap / Priority Queue
Always have instant access to the best remaining option. No re-sorting needed.
5 problemsLearn →Graph Traversal
Mark what you've visited. Start over for each component. Follow every edge once.
5 problemsLearn →Backtracking
Build the solution one choice at a time. Undo it when it doesn't work out.
5 problemsLearn →