LeetCode 100 Patterns Roadmap: Master Technical Interviews Without Grinding 1,000 Questions
A categorized roadmap covering 14 core Data Structures & Algorithms patterns tested in coding interviews.
Summary: Master technical coding interviews efficiently by understanding 14 foundational algorithmic patterns. Covers Two Pointers, Sliding Window, Fast/Slow Pointers, BFS/DFS, Top K Elements, and Dynamic Programming.
1. Why Pattern Recognition Beats Problem Memorization
Memorizing hundreds of individual LeetCode problems is ineffective and stressful. By mastering 14 core underlying algorithmic patterns, you can recognize problem structures and solve thousands of unseen technical interview questions during live interviews.
2. Comprehensive Breakdown of 14 Algorithmic Patterns
### 1. Two Pointers * **When to use:** Sorted arrays or strings searching for pairs or triplets. * **Canonical Problems:** Two Sum II, 3Sum, Container With Most Water, Valid Palindrome. ### 2. Sliding Window * **When to use:** Contiguous subarrays or substrings meeting a specific criteria. * **Canonical Problems:** Longest Substring Without Repeating Characters, Minimum Size Subarray Sum. ### 3. Fast & Slow Pointers (Floyd's Cycle Detection) * **When to use:** Detecting cycles in linked lists or cyclic arrays. * **Canonical Problems:** Linked List Cycle, Happy Number. ### 4. Merge Intervals * **When to use:** Overlapping intervals or scheduling problems. * **Canonical Problems:** Merge Intervals, Insert Interval, Meeting Rooms II. ### 5. In-place Reversal of Linked List * **When to use:** Reversing links between nodes without allocating extra memory. * **Canonical Problems:** Reverse Linked List, Reverse Nodes in k-Group. ### 6. Tree Breadth-First Search (BFS) * **When to use:** Level-order traversal of trees or finding shortest paths in unweighted graphs. * **Canonical Problems:** Binary Tree Level Order Traversal, Zigzag Level Order. ### 7. Tree Depth-First Search (DFS) * **When to use:** Pathfinding or root-to-leaf paths in trees/graphs. * **Canonical Problems:** Path Sum II, Lowest Common Ancestor. ### 8. Two Heaps * **When to use:** Tracking median values in streaming data. * **Canonical Problems:** Find Median from Data Stream. ### 9. Subsets & Backtracking * **When to use:** Generating all permutations, combinations, or decision trees. * **Canonical Problems:** Subsets, Permutations, N-Queens. ### 10. Modified Binary Search * **When to use:** Searching elements in rotated or boundary-sorted arrays. * **Canonical Problems:** Search in Rotated Sorted Array, Find Minimum in Rotated Sorted Array. ### 11. Top K Elements (Min/Max Heap) * **When to use:** Finding the k largest or smallest elements in a dataset. * **Canonical Problems:** Kth Largest Element in an Array, Top K Frequent Elements. ### 12. K-way Merge * **When to use:** Merging multiple sorted arrays or linked lists. * **Canonical Problems:** Merge k Sorted Lists. ### 13. Dynamic Programming (Memoization & Tabulation) * **When to use:** Problems with overlapping subproblems and optimal substructure. * **Canonical Problems:** Climbing Stairs, Coin Change, Longest Common Subsequence, 0/1 Knapsack. ### 14. Monotonic Stack * **When to use:** Finding the next greater or smaller element in an array. * **Canonical Problems:** Next Greater Element, Daily Temperatures, Largest Rectangle in Histogram.
3. Data Structures Complexity Reference Table
* **Array:** Access: O(1) | Search: O(N) | Insertion: O(N) | Space: O(N) * **Hash Table:** Access: N/A | Search: O(1) | Insertion: O(1) | Space: O(N) * **Binary Search Tree:** Access: O(log N) | Search: O(log N) | Insertion: O(log N) | Space: O(N) * **Stack / Queue:** Access: O(N) | Search: O(N) | Insertion: O(1) | Space: O(N) * **Heap / Priority Queue:** Peek: O(1) | Insert/Delete: O(log N) | Space: O(N)
4. The 4-Step Technical Interview Framework
1. **Understand & Clarify (2-3 mins):** Ask about constraints, array sizes, input types, and duplicate values. 2. **Outline Approach & Trade-offs (3-5 mins):** State brute-force solution first, then explain the optimized pattern and complexity. 3. **Write Clean Code (15-20 mins):** Use clear variable names and modular functions. 4. **Dry Run & Edge Case Test (5 mins):** Test edge cases (null inputs, empty arrays, single element) manually out loud.