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)

  1. List the 7 questions in the 30-second triage in order.
  2. For each input shape, name two candidate patterns: single array, sorted array, 2D grid, tree, graph, string, multiple intervals.
  3. For each output shape, name two patterns: count, min/max, all combinations, single index/pair.
  4. — what algorithmic complexity is acceptable?
  5. — what's your target complexity?
  6. "Subarray" / "contiguous" — which pattern?
  7. "Subsequence" — which pattern?
  8. "Top-K" — which pattern?
  9. "Connected" — which pattern(s)?
  10. "Shortest path, weighted, no negatives" — which?

Section B — Pattern recognition: arrays / hashing / two pointers / sliding window (Q11–25)

  1. "Find pair summing to target in sorted array" → pattern?
  2. "Find pair summing to target in unsorted array" → pattern?
  3. "Group anagrams" → pattern + key idea?
  4. "Top K frequent elements" → two patterns + complexities?
  5. "Longest substring without repeating chars" → pattern?
  6. "Min window substring containing all chars in T" → pattern?
  7. "Longest repeating character replacement (k changes)" → pattern + invariant?
  8. "Container with most water" → pattern + which side moves?
  9. "3Sum" → pattern + complexity?
  10. "Trapping rain water" → two-pass approach + alternative?
  11. "Best time to buy/sell stock (one transaction)" → pattern + state?
  12. "Maximum subarray sum" → name the algorithm.
  13. "Product of array except self" → pattern + technique?
  14. "Longest consecutive sequence" → pattern + key trick?
  15. "Permutation in string" → pattern?

Section C — Stack / monotonic stack (Q26–33)

  1. "Valid parentheses" → pattern?
  2. "Min stack" — two ways to design?
  3. "Daily temperatures" → pattern + monotonic-which-way?
  4. "Next greater element" → pattern?
  5. "Largest rectangle in histogram" → pattern + key insight?
  6. "Car fleet" → preprocessing + pattern?
  7. "Evaluate Reverse Polish Notation" → pattern?
  8. "Generate parentheses" → pattern (this is a trap)?

Section D — Binary search (Q34–43)

  1. When does binary search apply? Two requirements.
  2. "Find min in rotated sorted array" → pattern + key comparison?
  3. "Search in rotated sorted array" → pattern?
  4. "Search 2D matrix" → key trick?
  5. "Koko eating bananas" → pattern + what to BS on?
  6. "Median of two sorted arrays" → pattern + complexity?
  7. "Time-based key-value store" → pattern + per-key structure?
  8. "Capacity to ship packages within D days" → pattern?
  9. "Find peak element" → pattern + invariant?
  10. Difference between l <= r and l < r loop forms — when each?

Section E — Linked list (Q44–53)

  1. "Reverse linked list" → recursive + iterative templates?
  2. "Detect cycle" → algorithm name?
  3. "Find cycle entry" → algorithm + key step?
  4. "Merge two sorted lists" → pattern + dummy node?
  5. "Reorder list" → 3-step decomposition?
  6. "Remove Nth from end" → pattern?
  7. "Copy list with random pointer" → two approaches?
  8. "LRU cache" → data structures + complexities?
  9. "Merge K sorted lists" → two approaches + complexities?
  10. "Find the duplicate number (Floyd cycle on implicit graph)" → pattern + insight?

Section F — Trees (Q54–67)

  1. DFS template (recursive postorder, with return).
  2. BFS level-order template.
  3. "Invert binary tree" → recursion?
  4. "Maximum depth" — recurrence?
  5. "Diameter of binary tree" — what to track during recursion?
  6. "Balanced binary tree" — sentinel pattern?
  7. "Same tree" / "subtree" — pattern?
  8. "LCA in BST" — pattern + key BST property?
  9. "LCA in general tree" — DFS pattern + return condition?
  10. "Validate BST" — pattern + key parameter?
  11. "Right side view" — DFS or BFS approach?
  12. "Construct from preorder + inorder" — pattern?
  13. "Kth smallest in BST" — pattern?
  14. "Serialize / deserialize" — encoding choice?

Section G — Tries (Q68–72)

  1. When to reach for a trie?
  2. Insert / search / starts_with — complexities?
  3. "Add and search word with . wildcard" → pattern + DFS technique?
  4. "Word search II" → pattern + what's the trie used for?
  5. Trade-offs between trie and hash set.

Section H — Heap / priority queue (Q73–82)

  1. "Kth largest element in array" → two approaches + complexities?
  2. "Last stone weight" → pattern?
  3. "K closest points to origin" → pattern + heap size?
  4. "Task scheduler" → pattern + key data structures?
  5. "Find median from data stream" → pattern + invariant?
  6. "Merge K sorted lists" → heap formulation?
  7. "Top K frequent elements" → two approaches?
  8. "Design Twitter" → pattern?
  9. Python heapq — min or max heap by default?
  10. heapify complexity?

Section I — Backtracking (Q83–93)

  1. When to reach for backtracking?
  2. "Subsets" — include/exclude template?
  3. "Permutations" — swap-in-place vs used-array?
  4. "Combination sum" — start index + when to recurse?
  5. "Combination sum II (with duplicates)" — sort + skip-when?
  6. "Word search" — DFS + visited marker pattern?
  7. "Palindrome partitioning" — what do you try at each step?
  8. "N-queens" — what state to track for check?
  9. "Letter combinations of phone number" — recursion vs iterative?
  10. "Sudoku solver" — what 3 sets per cell?
  11. Common bug in backtracking when storing solutions?

Section J — Graphs (Q94–106)

  1. DFS template. BFS template.
  2. "Number of islands" → pattern?
  3. "Clone graph" → pattern + key data structure?
  4. "Pacific Atlantic water flow" → pattern (multi-source BFS)?
  5. "Surrounded regions" → key trick?
  6. "Rotting oranges" → pattern + state to track?
  7. "Walls and gates" → pattern?
  8. "Course schedule" → pattern + algorithm?
  9. "Course schedule II" → return what?
  10. "Word ladder" → pattern + how to build the graph?
  11. "Number of connected components" — two methods?
  12. "Graph valid tree" — three conditions?
  13. "Redundant connection" → pattern?

Section K — Advanced graphs (Q107–115)

  1. Topological sort — Kahn's vs DFS-based?
  2. Dijkstra — when applicable + complexity?
  3. Bellman-Ford — when over Dijkstra + complexity?
  4. Floyd-Warshall — when + complexity?
  5. MST — Kruskal vs Prim?
  6. "Network delay time" → pattern?
  7. "Cheapest flights within K stops" → pattern?
  8. "Min cost to connect all points" → pattern?
  9. "Reconstruct itinerary" → algorithm name?

Section L — 1D DP (Q116–127)

  1. When to reach for 1D DP?
  2. State definition: dp[i] for "Climbing Stairs".
  3. Coin Change — recurrence?
  4. Coin Change II (number of ways) — what changes?
  5. House Robber — recurrence?
  6. House Robber II — how to handle the circular constraint?
  7. Decode Ways — how to handle "0"?
  8. Word Break — recurrence + dictionary lookup?
  9. LIS — recurrence + trick name?
  10. Maximum Product Subarray — what state to track?
  11. Partition Equal Subset Sum — reduces to which classical?
  12. Longest palindromic substring — expand-around-centers vs DP?

Section M — 2D DP (Q128–138)

  1. When to reach for 2D DP?
  2. LCS — recurrence on equal vs unequal characters?
  3. Edit Distance — three operation costs.
  4. Distinct Subsequences — what's dp[i][j]?
  5. Interleaving String — boolean DP, what's the recurrence?
  6. Buy/sell with cooldown — state dimension?
  7. Best Time IV (k transactions) — state?
  8. Target Sum — reduces to subset sum count?
  9. Burst Balloons — why range DP, not interval-greedy?
  10. Regular Expression Matching — recurrence on *?
  11. Longest Increasing Path in matrix — DFS + memo or pure DP?

Section N — Greedy, intervals, math, bits (Q139–155)

  1. When does greedy work? How do you prove it?
  2. Maximum subarray (Kadane) — running sum logic?
  3. Jump Game II — greedy invariant?
  4. Gas station — pattern?
  5. Hand of Straights — pattern + data structure?
  6. Partition Labels — preprocessing + sweep?
  7. Insert Interval — three phases?
  8. Merge Intervals — sort by what?
  9. Non-overlapping intervals — greedy + sort by what?
  10. Meeting rooms II — sweep-line + heap method?
  11. Min interval to include each query — pattern?
  12. Rotate image — algorithm in two steps?
  13. Spiral matrix — boundary trick?
  14. Pow(x, n) — algorithm?
  15. Single Number — pattern?
  16. Counting Bits 0..n — recurrence?
  17. Sum of Two Integers without + — bit logic?

Section O — Senior signals (Q156–165)

  1. Show me the 5-step problem-solving protocol.
  2. What do you do in the first 2-5 minutes of a problem?
  3. What if you're stuck after 10 minutes?
  4. How do you state complexity properly?
  5. How do you test your code in an interview?
  6. How do you handle edge cases out loud?
  7. How do you communicate while coding?
  8. How do you ask clarifying questions without sounding lost?
  9. What's a common bug pattern in your code that you watch for?
  10. 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.