Patterns: Reusable Moves and Their Signals
There are thousands of practice problems, but only a dozen or so moves behind most of them. The people who seem to "just see" a solution are not faster at inventing. They have learned which few words in a problem point to which move, and they reach for it straight away.
The rule
Memorise moves and their signals, not individual problems.
A pattern is a reusable shape of solution with a known cost. Once you know the shape, a new problem becomes "which shape is this?" rather than "invent something from nothing". This course teaches six:
| Signal in the problem | Pattern | Usual cost |
|---|---|---|
| "seen before?", "a pair that adds to", "count", "group" | hash set or dictionary | one pass, extra memory |
| "total of a range", asked many times | prefix sums | one pass, then instant ranges |
| sorted input, pairs or triples, compare both ends | two pointers | one pass, no extra memory |
| sorted input, or "the smallest value that still works" | binary search | about log n checks |
| "consecutive", "substring", "longest or shortest stretch" | sliding window | one pass |
| "list all", "every combination", tiny limits | backtracking | exponential, fine for small n |
Two cautions. First, signals are hints, not proofs: you still check that the move really fits. Second, real problems often combine moves, such as a sliding window that keeps its counts in a dictionary.