The core patterns to master
Cover these and you can attack the large majority of DSA rounds.
- Two pointers & sliding window — subarray/substring problems with a contiguous range.
- Hashing — frequency counts, lookups, and de-duplication in O(1).
- Binary search — sorted arrays, and "search the answer space" variants.
- BFS / DFS — trees and graphs; level-order, connected components, shortest path.
- Dynamic programming — overlapping subproblems; start with the recurrence.
- Heaps — top-K, merge-K, and streaming-median problems.
- Backtracking — permutations, combinations, and constraint satisfaction.