Pattern Recognition Cheat Sheet
On this page
You don't recognise a pattern by remembering the problem. You recognise it from three things you can read in the first minute: how big the input is, what shape it has, and what the question asks for. This page puts those signals in one place. Each row links to a pattern page with the template and its common bugs.
Use it as a starting guess, not a rule. Many problems mix two patterns: LRU Cache is a hash map plus a linked list, and Minimum Window Substring is a sliding window plus counts.
Step 1: the input size sets the budget

If the constraints aren't given, ask. "How large can n get?" is one of the most useful questions in the interview, because it tells you which ideas are even worth trying. See Big-O for Interviews for how to count steps.
Step 2: the shape of the input

Try it yourself first
You have the full problem. Sketch your answer, then sign up free to read the complete walkthrough.
- The complete design, flow by flow, with pictures
- Deep dives into the hard parts
- What mid, senior and staff candidates are expected to say
- Full company question lists
Free forever. No card needed.