A pattern name is useful only when it helps you notice structure and defend a solution. If practice becomes a race to recall a template, the label is doing the reasoning for you.
Start with the signal
Before naming a pattern, write down the clue that changed the search space. A sorted input, a contiguous range, repeated membership checks, or an unweighted shortest path is more useful than a vague feeling that a problem “looks like” something you have seen before.
The signal should be specific enough to rule out at least one alternative. “This is an array problem” is not a signal. “The answer depends on a contiguous range whose state can be updated when either boundary moves” is.
State the invariant before the implementation
An invariant explains what remains true while the algorithm changes state. It is the bridge between recognition and correctness.
- A sliding window might maintain exactly the elements in the current candidate range.
- A binary search might preserve that every value before the left boundary is known to be invalid.
- A breadth-first search might guarantee that the first time a node is reached, it has been reached with the fewest edges.
If you cannot say what remains true, pause before coding. The missing sentence is often the source of the later off-by-one error or invalid state transition.
Practice the contrast
After solving a problem, ask what small change would make the chosen pattern wrong. If negative values were allowed, would the window still move monotonically? If edges carried different weights, would breadth-first search still be enough? If the input were not ordered, could binary search discard half safely?
This contrast builds a boundary around the pattern. Boundaries transfer better than memorized code because they tell you both when to use an approach and when to reject it.
Use a short, repeatable loop
- Attempt one problem without a visible pattern label.
- Record the recognition signal and the invariant in plain language.
- Identify one plausible alternative and explain why it loses.
- Rebuild the solution from those statements instead of from a template.
- Return later and solve a nearby problem with different surface details.
The pattern index is designed for this loop: use it to diagnose a weak area, study the reasoning, and then move to the question library without keeping the label in view.
What to record after each attempt
Keep the note small: the clue, the invariant, the mistake, and the condition that would change your approach. That is enough evidence to make the next attempt more deliberate without turning practice into a second documentation project.