Pattern Recognition — Keywords to Technique
Triage a problem statement into a pattern bucket, then read the linked pattern note for recipes and templates.
Index: Patterns README
Mermaid flowchart (keyword triage)
Use camelCase node IDs with no spaces. Follow arrows from your best keyword match.
Pattern → doc link
| Bucket | Pattern guide |
|---|---|
| TwoPointers | Two pointers |
| SlidingWindow | Sliding window |
| FastSlow | Fast & slow pointers |
| BinarySearch | Binary search |
| BFS | BFS |
| DFS | DFS / backtracking |
| Heap | Top-K / heap |
| TopoSort | Topological sort |
| UnionFind | Union-Find |
| Trie | Trie |
| MonotonicStack | Monotonic stack |
| PrefixSum | Prefix sum |
| Bit | Bit manipulation |
| DP | Dynamic programming |
| Greedy | Greedy |
| DivideConquer | Divide & conquer |
Related patterns not shown as graph terminals: Merge intervals, Cyclic sort, Linked list reversal, Tree DFS.
Text decision tree (backup)
-
Input sorted / orderable to sorted
-
Contiguous substring/subarray with a constraint (longest/shortest/fixed)
→ Sliding Window (02). -
Linked list: cycle, middle, k-from-end
→ Fast & Slow (03); reversal variants → 10. -
Graph / tree
-
Top-k, streaming median, Dijkstra frontier
→ Heap (07). -
Prerequisites / course schedule / build order
→ Topological sort (12). -
Dynamic connectivity / redundant connection / Kruskal-like
→ Union-Find (13). -
Prefix search / dictionary / autocomplete on strings
→ Trie (14). -
“Next greater / smaller element”, histogram, temperature stack
→ Monotonic stack (15). -
Static range sums / difference-array style updates
→ Prefix sum / difference (16). -
XOR uniqueness, subset enumeration with bitmask
→ Bit manipulation (17). -
Overlapping subproblems + optimal substructure
→ often DP (18); Greedy (19) when exchange argument holds; Divide & conquer (20) when subproblems are independent halves.
Cheatsheet peers: Big-O complexity, Data structure operations.
Last updated on
Spotted something unclear or wrong on this page?