This document lists the core algorithmic patterns that cover 90–95% of FAANG-level coding interview problems.
Mastering these patterns to procedural fluency enables solving medium problems in 2–5 minutes.
- Reverse Linked List (iterative)
- Merge Two Lists (dummy head pattern)
- Partition Into Two Lists (small/big dummy heads)
- Fast/Slow Pointers
- middle of list
- cycle detection (Floyd)
- reorder list
- Remove/Skip Nodes With Dummy
- remove Nth from end
- skip duplicates
- delete specific node pattern
- Two-Pointer Convergence (sorted arrays)
- Opposing Pointers for Optimization (max/min problems)
- Sliding Window – Fixed Size
- Sliding Window – Variable Size
- Sliding Window – Longest Substring With Constraints
- Sliding Window – Shortest Substring With Constraints
- Prefix Sums + Hashmap
- Subarray Sum = K Pattern
- Dutch National Flag (3-Way Partition)
- Monotonic Increasing Stack
- next greater element
- stock span
- Monotonic Decreasing Stack
- largest rectangle in histogram
- max rectangle in matrix
- Parentheses Stack Patterns
- valid parentheses
- minimum removals
- longest valid parentheses
- Sliding Window Max/Min Using Deque
- BFS Level-Order Traversal
- BFS Shortest Path in Grid Graph
- Standard Binary Search Template
- Binary Search on Answer (parametric search)
- Lower-Bound / Upper-Bound
- Search in Rotated Sorted Array
- DFS Recursion Patterns
- preorder
- inorder
- postorder
- BFS Tree Traversal
- Lowest Common Ancestor
- binary tree
- binary search tree
- Diameter / Depth Patterns
- max depth
- diameter of binary tree
- Binary Tree Serialization / Deserialization (BFS-based)
- BST Insert / Delete / Search (conceptual + implementation)
- DFS Graph Template
- BFS Graph Template
- Topological Sort (Kahn’s Algorithm)
- Cycle Detection in Directed Graph
- DFS recursion stack
- Kahn’s indegree method
- Connected Components (BFS or DFS)
- Union-Find (Disjoint Set Union)
- path compression
- union by rank
- Dijkstra’s Algorithm (Min-Heap Pattern)
- Fibonacci / Linear DP Template
- Knapsack DP
- classic 2D
- optimized 1D rolling array
- Subsequence DP
- LCS
- edit distance
- LIS
- Palindrome DP
- palindromic substrings
- longest palindromic substring
- Partition DP
- subset sum
- equal partition
- Interval DP
- burst balloons
- matrix chain multiplication
- Bitmask DP (rare, niche)
- Sort + Merge Intervals
- Insert Interval
- Select Maximum Non-Overlapping Intervals (classic greedy)
- Gas Station / Circular Tour
- Meeting Rooms Scheduling (heap-based)
- Kth Largest Element
- min-heap of size k
- quickselect
- Top-K Frequency (heap or bucket sort)
- Heap-Select Patterns
- Prefix Product / Postfix Product (product of array except self)
- Sweep Line
- Reservoir Sampling
- Randomized Quickselect
Core patterns to master: 51
These are sufficient to solve nearly all FAANG-level technical interview questions with speed and confidence.
- Treat these as templates, not problems.
- Drill 3 patterns per day for 10–15 minutes.
- Aim for procedural fluency: solutions should be reflexive, fast, automatic.
- Build a repo with one directory per pattern containing:
- Python template
- Example problems
- Practice implementations
- Notes + pitfalls
Master these → Mediums become trivial, hards become mechanical.
patterns/01-linked-list-reverse/: core iterative reverse template with notes.patterns/01_linked_list_patterns.py: full linked list pattern implementations (reverse, merge, partition, fast/slow, remove with dummy).patterns/02_two_pointers_and_windows.py: two-pointer + sliding window patterns (fixed, variable, prefix-sum/hash) ready to use.shared/: reusable structures such asListNodeplus build/print helpers.