DSA Patterns Roadmap
A structured path from foundational patterns to advanced FAANG techniques. Follow the tiers in order โ each pattern builds on the last.
Foundational Patterns
Core building blocks every other pattern depends on. Start here.
Hashing (Maps & Sets)
O(1) lookups for frequency counting and duplicate detection
Two Pointers
Converge from both ends to find pairs in sorted data
Sliding Window
Maintain a dynamic window over contiguous elements
Prefix Sum
Precompute cumulative sums for O(1) range queries
Binary Search
Halve the search space each step on sorted data
Sorting + Custom Comparators
Sort to unlock greedy, two-pointer, and interval techniques
Stack
LIFO for bracket matching, undo, and DFS iteration
Recursion
Solve problems by solving smaller versions of themselves
Linked List Techniques
Pointer manipulation for reversal, merge, and partitioning
Composite Patterns
Combines beginner patterns. Most FAANG medium problems live here.
Fast & Slow Pointers
Detect cycles and find midpoints with two-speed traversal
Monotonic Stack
Next greater/smaller element in O(n)
Queue / Deque
FIFO for BFS and sliding window max/min
Heap / Priority Queue
Efficiently track top-K or merge-K sorted streams
Greedy Algorithms
Locally optimal choices that lead to global optimum
Tree Traversals (DFS/BFS)
Visit every node systematically in hierarchical structures
BST Concepts
Exploit sorted in-order property for O(log n) operations
Backtracking
Explore all candidates with pruning for constraint satisfaction
Graph Traversals (DFS/BFS)
Explore connected nodes for islands, paths, and components
Interval Problems
Sort and sweep to merge, insert, or find overlaps
Difference Array
Apply range updates in O(1) each, reconstruct with prefix sum
High-Value FAANG Patterns
Complex patterns for hard-level interviews. Tackle these last.
Dynamic Programming
Cache overlapping subproblems โ 1D, 2D, knapsack, LIS
Topological Sort
Order nodes respecting dependency constraints in DAGs
Union Find (Disjoint Set)
Track and merge connected components in near O(1)
Trie (Prefix Tree)
Fast prefix-based lookups for autocomplete and word search
Divide & Conquer
Split, solve halves independently, combine results
Bit Manipulation
XOR tricks, bitmask DP, and O(1) integer operations
Ready to go deeper?
The detailed guide covers every pattern with intuition, code examples, practice problems, and a pattern recognition framework.
Open the Complete Guide