Algorithmic Patterns
Recognising the shape of a problem before solving it.
Questions
Easy / Med / Hard
Your accuracy
Most interview problems are variations on a small set of patterns. Recognising the pattern is most of the work, and it is what lets you talk through an approach confidently before writing a line.
Two pointers — a sorted array with a pair or triple condition. Converts O(n²) scanning into O(n) by moving pointers inward based on the comparison.
Sliding window — contiguous subarrays or substrings with a constraint. Expand the right edge, contract the left when the constraint breaks. O(n) instead of O(n²).
Fast and slow pointers — cycle detection in a linked list, or finding the middle in one pass.
Binary search on the answer — the classic tell is "minimum X such that a condition holds," where the condition is monotonic. You are not searching an array, you are searching the answer space.
BFS vs DFS — BFS finds shortest paths in unweighted graphs and explores level by level; DFS is natural for exhaustive exploration, path finding, and anything recursive on trees. Weighted shortest path means Dijkstra instead.
Dynamic programming — overlapping subproblems plus optimal substructure. Start from the recurrence, then decide memoisation versus tabulation. Being able to state the recurrence out loud matters more than the implementation.
Heap for top-k, trie for prefixes, union-find for connectivity — each has a distinctive tell.
Say the pattern out loud when you spot it: "this is a sliding window, because we need the longest contiguous run satisfying a constraint." That sentence is the signal being measured.