FreeLesson 0.2Beginner2 min readUpdated 30 October 2026
Which pattern? A map from clues to techniques
The words in a problem statement that hint at each pattern, so you can pick a starting point in the first minute.
Most interview problems give their pattern away in the wording. Read the question, look for these clues, and you'll usually know where to start.
01Clue → pattern
| If the problem says… | Try |
|---|---|
| "Have I seen this before?", duplicates, counts, "group by" | Arrays and hashing |
| Sorted array, "pair that adds up to", palindrome, "in place" | Two pointers |
| "Longest / shortest subarray or substring" with a condition | Sliding window |
| Sorted data, "find the smallest X such that…", O(log n) asked | Binary search |
Nodes with next, "reverse", "cycle", "middle" | Linked lists |
| Matching brackets, "next greater", undo, most recent first | Stacks and queues |
| The problem is a smaller copy of itself | Recursion |
| "All combinations / permutations / subsets", "every way to" | Backtracking |
| Root, children, depth, "level by level" | Trees |
| Grid of cells, islands, "shortest path in steps" | BFS, DFS and grids |
| Dependencies, "order of tasks", connections between many things | Graphs |
| "How many ways", "minimum cost", choices that overlap | Dynamic programming |
| Prefixes, autocomplete, "words starting with" | Trie |
02How to use this map
- Underline the clue words in the question.
- Pick the pattern from the table and write its skeleton pseudocode.
- Fit the details: what goes in the map, what the two pointers mean, when the window shrinks.
03Input size tells you the speed you need
| n up to | Usually fine |
|---|---|
| 20 | O(2ⁿ) backtracking |
| 1,000 | O(n²) |
| 100,000 | O(n log n) or O(n) |
| 10⁹ | O(log n) or O(1) |