What are the patterns?
Two pointers, sliding window, binary search on answer, BFS/DFS, topological sort, heap/top-k, intervals, DP, backtracking, union-find.
Guide · Career
Interview problems are drawn from a small set of recurring shapes. Solving 400 problems randomly teaches you 400 facts; identifying which of ten patterns you keep failing teaches you the thing that transfers.
"I did 300 problems" tells you nothing about readiness, because it does not distinguish between 300 problems in the patterns you already know and 300 spread across the ones you do not. Volume without a diagnosis produces a common and frustrating outcome: a large solved count and a consistent failure on any problem phrased slightly unfamiliarly.
The reframe is simple. An interview problem is a pattern wearing a costume. Your job in the first two minutes is to identify the pattern; the implementation afterwards is mechanical if you have drilled it. So practice should be organised around recognising patterns and around finding the ones where your recognition fails.
| Pattern | Recognition cue | Typical complexity |
|---|---|---|
| Two pointers | Sorted array, pair or triplet sum, in-place partition, palindrome | O(n) after any sort |
| Sliding window | Contiguous subarray or substring, longest or shortest satisfying a condition | O(n) |
| Binary search on the answer | Monotone predicate, "minimum k such that…", "can we do it in x?" | O(n log range) |
| BFS / DFS on graphs | Grid, tree, connectivity, shortest path with unit edges, reachability | O(V + E) |
| Topological sort | Dependencies, prerequisites, ordering with constraints, cycle detection | O(V + E) |
| Heap / top-k | K largest, k closest, merge k sorted, running median | O(n log k) |
| Intervals | Meetings, ranges, merges, overlaps, scheduling | O(n log n) with sort |
| Dynamic programming | Count the ways, optimal value, overlapping subproblems, choices per index | Depends on state space |
| Backtracking | Generate all, permutations, combinations, constraint satisfaction, N-queens | Exponential with pruning |
| Union-find | Connected components, grouping, cycle detection in undirected graphs, Kruskal | Near O(α(n)) per op |
That table is most of the surface area of a standard software interview loop. The remaining problems are usually combinations — a BFS whose frontier is a heap, a DP over intervals, a binary search whose predicate runs a greedy check.
Recognition is a separate skill from implementation and it is the one that fails under pressure. Drill it separately: read a problem, spend two minutes deciding the pattern and the complexity target, write it down, then check. Do not implement. You can run twenty of these in the time one full solution takes, and it trains exactly the step interviews test first.
For each problem, before coding, answer four questions: 1. What is the input shape? sorted / graph / intervals / string 2. What is being asked? exists / count / optimum / enumerate 3. What complexity is plausible? n log n suggests sort or heap or binary search 4. Which pattern fits? name it, out loud, before typingQuestion 3 does more work than people expect. If the constraints allow n up to 10^5, an O(n^2) solution is not the intended one, and that single observation frequently identifies the pattern on its own.
The whole method rests on one artefact: a log where every problem you attempt is tagged with its pattern and an outcome. Not a count — a per-pattern record.
The failure location matters as much as the failure. If you recognise sliding window instantly but keep mishandling the shrink condition, you do not need more sliding-window problems — you need to write the template once, correctly, and rehearse it. If you never recognise it in the first place, the fix is the opposite.
Algorithm knowledge decays like anything else. A problem solved cleanly in March is often a blank in June. Spaced repetition solves this cheaply: re-attempt solved problems on an expanding schedule rather than solving new ones forever.
| Outcome | Next review | Rationale |
|---|---|---|
| Failed | 1 day | Nothing has been learned yet |
| Solved with a hint | 3 days | Recognition is fragile |
| Solved unaided, slowly | 1 week | Correct but not fluent |
| Solved unaided, fluently | 3 weeks | Maintenance only |
| Fluent twice in a row | 2 months | Retired to background rotation |
The practical shape is a Leitner system: boxes with review intervals, a problem moves forward on a clean solve and drops back to box one on a failure. Twenty minutes of review before new problems each session is a better use of the hour than another fresh problem.
The honest test of readiness is not a solved count. It is whether you can be handed an unfamiliar problem in any of the ten patterns and name the pattern within two minutes, then implement its template without looking it up.
The rest of the search — which roles, which deadlines, and the sponsorship questions if you need them — is covered in the internship guide, and the pipeline itself lives in Apply OS.
FAQ
Two pointers, sliding window, binary search on answer, BFS/DFS, topological sort, heap/top-k, intervals, DP, backtracking, union-find.
A count cannot tell known patterns from unknown ones. Volume without diagnosis leaves you failing anything phrased unfamiliarly.
Input shape, what is asked, plausible complexity, then name it. Constraints alone often rule out the wrong approach.
Pattern, outcome, and where it broke — recognition, approach, implementation, or edge cases. Each needs a different fix.
Re-solve on expanding intervals: 1 day after a fail, 3 days after a hint, 1 week, 3 weeks. Leitner boxes, review before new problems.
When an unfamiliar problem in any pattern gets named in two minutes and the template gets written without a lookup.