You've learned all 12 interview patterns. In a real interview, nobody tells you which one a problem needs. This final part trains exactly that skill: read a problem, spot the signals, name the pattern. 30 problems, instant feedback, and a score for each pattern so you know what to revise.
The 12 interview patterns: you are here
- 1Two Pointerssorted + pair
- 2Sliding Windowcontiguous subarray
- 3Prefix Sum + Hash Maprange sums, sum = K
- 4Binary Search on Answersmallest value that works
- 5Fast & Slow Pointerscycle, middle
- 6Merge Intervalsoverlapping ranges
- 7Monotonic Stacknext greater element
- 8Heap / Top-Ktop K, Kth largest
- 9Tree Patternsdepth, paths, levels
- 10Grid BFS & Topological Sortislands, dependencies
- 11Backtrackingall combinations
- 12DP Patternscount ways, min cost
The cheat sheet: signal → pattern
| When you see… | Try… |
|---|---|
| “sorted” + pair or target sum | Two Pointers |
| longest / shortest substring in a row | Sliding Window |
| range sums, “subarray sum = K” | Prefix Sum + Hash Map |
| “minimum … such that” | Binary Search on Answer |
| linked list cycle or middle | Fast & Slow Pointers |
| [start, end] pairs that overlap | Merge Intervals |
| “next greater / warmer day” | Monotonic Stack |
| “top K”, “Kth largest” | Heap / Top-K |
| depth, paths, level by level | Tree Patterns |
| islands, “prerequisites” | Grid BFS & Topological Sort |
| “all subsets / permutations” | Backtracking |
| count ways, min cost, overlap | DP Patterns |
The challenge: 30 problems, no labels
Pick a pattern for each problem. Don't overthink it: interviews reward the first good instinct, explained clearly.
Given a sorted array, find two numbers that add up to a target.
Let the size limits help you
The constraints in a problem quietly tell you how fast your solution must be, and that narrows the patterns:
| Input size | Time you can afford | Likely patterns |
|---|---|---|
| n ≤ 20 | 2ⁿ or n! is fine | Backtracking (all subsets, permutations) |
| n ≤ 2,000 | O(n²) is fine | Simple DP tables, nested loops |
| n ≤ 10⁵ to 10⁶ | Need O(n log n) or O(n) | Sorting, two pointers, sliding window, prefix sum, heap, monotonic stack, BFS |
| Answer up to 10⁹, with a yes/no check | O(n log range) | Binary search on the answer |
🧠 PATH memory card
Remember all 12 patterns for good
Picture it · Anchor it · Trace it · Hit-recall it. Four quick steps that turn “I read it once” into “I can explain it in an exam”.
- P
Picture it
Your brain remembers scenes far better than definitions.
← swipe to see the whole picture →
Twelve pattern badges around one question: which pattern does this problem need?
- A
Anchor it
A silly sentence you can't forget, where every word maps to the concept.
“Shape, ask, size: then match the signal”
- Shape→Sorted array, linked list, tree, grid, intervals?
- Ask→Pair, stretch, top K, next greater, all combos, count or best?
- Size→Constraints tell you the speed you need
- Signal→Match the words to one of the 12 patterns
- T
Trace it
Run it by hand on a tiny example once. Doing beats reading.
“Fewest minutes until all oranges rot”: shape = grid, ask = fewest steps, size = up to 10⁵ cells → grid BFS from all rotten oranges at once. - H
Hit-recall it
Test yourself now, then again on the day each card comes back.
Card 1 / 12 · new0 mastered · 0 practisedSay the answer out loud first, then flip and be honest.
You finished the DSA course 🎉
From Big O to the 12 interview patterns, you now have the full toolkit that coding interviews test. Keep it fresh with a few flashcards a day, solve the problems listed in each pattern lesson, and when you're ready for the next round of interviews, continue with the System Design course.
Key takeaways
- ✓Read every problem for its shape, its ask and its size.
- ✓Match the signal words to one of the 12 patterns.
- ✓Constraints tell you the speed you need, which narrows the choice.
- ✓Say the pattern and its cost out loud before you code.
- ✓Practise mixed problems; revise any pattern you scored low on.
Frequently asked questions
How do I identify which DSA pattern to use?
Read three things: the shape of the input (sorted array? linked list? tree? grid? list of intervals?), what is asked (a pair, a contiguous stretch, top K, next greater, all combinations, a count or minimum?) and the size limits (they tell you how fast your solution must be). Then match the signal words to a pattern.
What do the constraints tell me?
Roughly: n up to about 20 allows exponential backtracking (2ⁿ); up to a few thousand allows O(n²); up to 10⁵–10⁶ needs O(n log n) or O(n) (sorting, two pointers, sliding window, heaps, prefix sums); answers up to 10⁹ with a yes/no check often mean binary search on the answer.
What if two patterns seem to fit?
That's common, and both can be valid. Pick the one that matches the most signals and the constraints, say why out loud in the interview, and mention the alternative. For example, a pair sum on unsorted data can use a hash map (O(n)) or sort + two pointers (O(n log n)).
How should I practise after this course?
For each pattern, solve the easy and medium problems in its “one pattern, many problems” table without looking at solutions, then mix them up. Before coding, always say the pattern and why. Review the flashcards in each lesson so the signals stay fresh.
Checking your access…