LeetCode Patterns Guide
This is not just a pattern index. It is an interview-oriented guide to when a pattern should come to mind, why it works, where it breaks, and how to practice it efficiently.
Core patterns
12+
Problem pages
64+
Practice flow
Recognize -> solve -> review
Common target complexity
O(n) / O(log n)
Pattern Index
Each pattern page goes beyond a template and explains recognition signals, common variants, likely traps, and a practical practice order.
Subarray and substring problems with contiguous ranges.
The problem asks about a contiguous range, substring, or subarray.
Pointer movement on arrays, strings, and linked structures.
The answer depends on comparing two positions and deciding which side should move.
Monotonicity, boundary search, and answer-space search.
You can define a predicate that changes only once across the search space.
State design, recurrence, and transition order.
You are optimizing, counting, or checking feasibility over many overlapping subproblems.
Traversal patterns for trees, graphs, and grids.
The input is a tree, graph, matrix, or implicit graph of states.
Connectivity and component merging problems.
The problem is about connectivity after repeated merge operations.
Repeatedly access the current min, max, or top-k frontier.
You repeatedly need the current smallest, largest, or earliest finishing item.
Nearest greater/smaller and boundary discovery.
The problem asks for the next greater, next smaller, or nearest boundary element.
Range sums, hash + prefix counts, and query compression.
The problem asks for many range sums or counts over ranges.
Local choices backed by exchange or boundary arguments.
A local choice seems obvious and you can argue why delaying it never helps.
Systematic search with choice, recurse, and undo.
The problem asks for all combinations, permutations, subsets, or valid constructions.
Bit tricks, state compression, and integer-level reasoning.
The problem talks about subsets, masks, parity, or binary states explicitly.
A more interview-effective practice order
Start with sliding window, two pointers, and binary search to improve pattern recognition speed.
Then move into dynamic programming and BFS/DFS for state design and traversal thinking.
Finish with union find, monotonic stack, heaps, and backtracking to round out hard-problem coverage.
How to use this pattern library more effectively
- check_circleUse pattern pages to build recognition first, then jump into representative problems for full solutions and code.
- check_circleMastering three to six good representative problems per pattern is usually better than blindly grinding dozens.
- check_circleIf your interview is close, prioritize high-frequency medium problems and revisit the most common follow-ups later.