DSA Patterns
Arrays & Strings / Two Pointers
Use for reverse/subarray ops, palindrome/anagram checks, partitioning, dedupe, pair/sum problems.
Sliding Window
Use for longest/shortest subarray satisfying constraint, distinct chars, “at most K” style.
Hash Map / Set
Use for counts, de-dupe, lookups, two-sum, anagrams, prefix sums.
Sorting + Intervals
Use for sweep/merge, greedy choices, custom ordering.
Binary Search (index & answer-space)
Use for search in sorted, “min x such that feasible(x)”, peaks, rotated arrays.
Prefix Sums & Counting
Use for range sums, balance, “# of subarrays with target”.
Stack (incl. Monotonic)
Use for parentheses/validity, next greater/smaller, histogram/areas.
Queue / Deque (Monotonic Queue)
Use for sliding window max/min in O(n), BFS level order.
Graphs & Grids (BFS/DFS/Topo)
Use for components, shortest path in unweighted, island counting, topological sort (DAG).
Trees (Binary Tree & BST)
Use for traversals (in/pre/post/level), path sums, LCA, BST properties.
Backtracking
Use for permutations, combinations, subsets, N-queens, phone digits.