LeetCode / NeetCode 150 — Interview Grill (Pattern Recognition)
150+ pattern-recognition questions — read the problem statement, name the pattern in <30 seconds. Pair with
LEETCODE_PATTERNS_DEEP_DIVE.md.
The point of these questions is not solving — it's identifying which template to deploy. Speed of recognition is the leverage skill.
Section A — The triage (Q1–10)
- List the 7 questions in the 30-second triage in order.
- For each input shape, name two candidate patterns: single array, sorted array, 2D grid, tree, graph, string, multiple intervals.
- For each output shape, name two patterns: count, min/max, all combinations, single index/pair.
- — what algorithmic complexity is acceptable?
- — what's your target complexity?
- "Subarray" / "contiguous" — which pattern?
- "Subsequence" — which pattern?
- "Top-K" — which pattern?
- "Connected" — which pattern(s)?
- "Shortest path, weighted, no negatives" — which?
Section B — Pattern recognition: arrays / hashing / two pointers / sliding window (Q11–25)
- "Find pair summing to target in sorted array" → pattern?
- "Find pair summing to target in unsorted array" → pattern?
- "Group anagrams" → pattern + key idea?
- "Top K frequent elements" → two patterns + complexities?
- "Longest substring without repeating chars" → pattern?
- "Min window substring containing all chars in T" → pattern?
- "Longest repeating character replacement (k changes)" → pattern + invariant?
- "Container with most water" → pattern + which side moves?
- "3Sum" → pattern + complexity?
- "Trapping rain water" → two-pass approach + alternative?
- "Best time to buy/sell stock (one transaction)" → pattern + state?
- "Maximum subarray sum" → name the algorithm.
- "Product of array except self" → pattern + technique?
- "Longest consecutive sequence" → pattern + key trick?
- "Permutation in string" → pattern?
Section C — Stack / monotonic stack (Q26–33)
- "Valid parentheses" → pattern?
- "Min stack" — two ways to design?
- "Daily temperatures" → pattern + monotonic-which-way?
- "Next greater element" → pattern?
- "Largest rectangle in histogram" → pattern + key insight?
- "Car fleet" → preprocessing + pattern?
- "Evaluate Reverse Polish Notation" → pattern?
- "Generate parentheses" → pattern (this is a trap)?
Section D — Binary search (Q34–43)
- When does binary search apply? Two requirements.
- "Find min in rotated sorted array" → pattern + key comparison?
- "Search in rotated sorted array" → pattern?
- "Search 2D matrix" → key trick?
- "Koko eating bananas" → pattern + what to BS on?
- "Median of two sorted arrays" → pattern + complexity?
- "Time-based key-value store" → pattern + per-key structure?
- "Capacity to ship packages within D days" → pattern?
- "Find peak element" → pattern + invariant?
- Difference between
l <= randl < rloop forms — when each?
Section E — Linked list (Q44–53)
- "Reverse linked list" → recursive + iterative templates?
- "Detect cycle" → algorithm name?
- "Find cycle entry" → algorithm + key step?
- "Merge two sorted lists" → pattern + dummy node?
- "Reorder list" → 3-step decomposition?
- "Remove Nth from end" → pattern?
- "Copy list with random pointer" → two approaches?
- "LRU cache" → data structures + complexities?
- "Merge K sorted lists" → two approaches + complexities?
- "Find the duplicate number (Floyd cycle on implicit graph)" → pattern + insight?
Section F — Trees (Q54–67)
- DFS template (recursive postorder, with return).
- BFS level-order template.
- "Invert binary tree" → recursion?
- "Maximum depth" — recurrence?
- "Diameter of binary tree" — what to track during recursion?
- "Balanced binary tree" — sentinel pattern?
- "Same tree" / "subtree" — pattern?
- "LCA in BST" — pattern + key BST property?
- "LCA in general tree" — DFS pattern + return condition?
- "Validate BST" — pattern + key parameter?
- "Right side view" — DFS or BFS approach?
- "Construct from preorder + inorder" — pattern?
- "Kth smallest in BST" — pattern?
- "Serialize / deserialize" — encoding choice?
Section G — Tries (Q68–72)
- When to reach for a trie?
- Insert / search / starts_with — complexities?
- "Add and search word with
.wildcard" → pattern + DFS technique? - "Word search II" → pattern + what's the trie used for?
- Trade-offs between trie and hash set.
Section H — Heap / priority queue (Q73–82)
- "Kth largest element in array" → two approaches + complexities?
- "Last stone weight" → pattern?
- "K closest points to origin" → pattern + heap size?
- "Task scheduler" → pattern + key data structures?
- "Find median from data stream" → pattern + invariant?
- "Merge K sorted lists" → heap formulation?
- "Top K frequent elements" → two approaches?
- "Design Twitter" → pattern?
- Python
heapq— min or max heap by default? heapifycomplexity?
Section I — Backtracking (Q83–93)
- When to reach for backtracking?
- "Subsets" — include/exclude template?
- "Permutations" — swap-in-place vs used-array?
- "Combination sum" — start index + when to recurse?
- "Combination sum II (with duplicates)" — sort + skip-when?
- "Word search" — DFS + visited marker pattern?
- "Palindrome partitioning" — what do you try at each step?
- "N-queens" — what state to track for check?
- "Letter combinations of phone number" — recursion vs iterative?
- "Sudoku solver" — what 3 sets per cell?
- Common bug in backtracking when storing solutions?
Section J — Graphs (Q94–106)
- DFS template. BFS template.
- "Number of islands" → pattern?
- "Clone graph" → pattern + key data structure?
- "Pacific Atlantic water flow" → pattern (multi-source BFS)?
- "Surrounded regions" → key trick?
- "Rotting oranges" → pattern + state to track?
- "Walls and gates" → pattern?
- "Course schedule" → pattern + algorithm?
- "Course schedule II" → return what?
- "Word ladder" → pattern + how to build the graph?
- "Number of connected components" — two methods?
- "Graph valid tree" — three conditions?
- "Redundant connection" → pattern?
Section K — Advanced graphs (Q107–115)
- Topological sort — Kahn's vs DFS-based?
- Dijkstra — when applicable + complexity?
- Bellman-Ford — when over Dijkstra + complexity?
- Floyd-Warshall — when + complexity?
- MST — Kruskal vs Prim?
- "Network delay time" → pattern?
- "Cheapest flights within K stops" → pattern?
- "Min cost to connect all points" → pattern?
- "Reconstruct itinerary" → algorithm name?
Section L — 1D DP (Q116–127)
- When to reach for 1D DP?
- State definition:
dp[i]for "Climbing Stairs". - Coin Change — recurrence?
- Coin Change II (number of ways) — what changes?
- House Robber — recurrence?
- House Robber II — how to handle the circular constraint?
- Decode Ways — how to handle "0"?
- Word Break — recurrence + dictionary lookup?
- LIS — recurrence + trick name?
- Maximum Product Subarray — what state to track?
- Partition Equal Subset Sum — reduces to which classical?
- Longest palindromic substring — expand-around-centers vs DP?
Section M — 2D DP (Q128–138)
- When to reach for 2D DP?
- LCS — recurrence on equal vs unequal characters?
- Edit Distance — three operation costs.
- Distinct Subsequences — what's
dp[i][j]? - Interleaving String — boolean DP, what's the recurrence?
- Buy/sell with cooldown — state dimension?
- Best Time IV (k transactions) — state?
- Target Sum — reduces to subset sum count?
- Burst Balloons — why range DP, not interval-greedy?
- Regular Expression Matching — recurrence on
*? - Longest Increasing Path in matrix — DFS + memo or pure DP?
Section N — Greedy, intervals, math, bits (Q139–155)
- When does greedy work? How do you prove it?
- Maximum subarray (Kadane) — running sum logic?
- Jump Game II — greedy invariant?
- Gas station — pattern?
- Hand of Straights — pattern + data structure?
- Partition Labels — preprocessing + sweep?
- Insert Interval — three phases?
- Merge Intervals — sort by what?
- Non-overlapping intervals — greedy + sort by what?
- Meeting rooms II — sweep-line + heap method?
- Min interval to include each query — pattern?
- Rotate image — algorithm in two steps?
- Spiral matrix — boundary trick?
- Pow(x, n) — algorithm?
- Single Number — pattern?
- Counting Bits 0..n — recurrence?
- Sum of Two Integers without
+— bit logic?
Section O — Senior signals (Q156–165)
- Show me the 5-step problem-solving protocol.
- What do you do in the first 2-5 minutes of a problem?
- What if you're stuck after 10 minutes?
- How do you state complexity properly?
- How do you test your code in an interview?
- How do you handle edge cases out loud?
- How do you communicate while coding?
- How do you ask clarifying questions without sounding lost?
- What's a common bug pattern in your code that you watch for?
- How do you decide between brute force vs optimal in an interview?
Self-grading
- 130+ correct: ready for big-tech / frontier-lab coding rounds.
- 95–129: re-read the deep dive and drill weak patterns.
- 60–94: spend a week on full deep dive + 5 problems per weak pattern.
- <60: build pattern foundations from §2–§19; one section per day for two weeks.
8-week drill plan (mapped to NeetCode 150)
- Week 1: Arrays & Hashing, Two Pointers, Sliding Window. Drill A, B.
- Week 2: Stack, Binary Search, Linked List. Drill C, D, E.
- Week 3: Trees, Tries, Heap. Drill F, G, H.
- Week 4: Backtracking, Graphs. Drill I, J.
- Week 5: Advanced Graphs. Drill K.
- Week 6: 1D DP. Drill L.
- Week 7: 2D DP. Drill M.
- Week 8: Greedy, Intervals, Math, Bits + mock interviews. Drill N, O.
Daily: 1 problem solo (30 min) → check editorial → re-attempt next day from scratch.