Frequency Map
Count or index values so repeated scanning becomes direct lookup.
Two Pointers
Move two indices under an invariant to avoid testing every pair.
Sliding Window
Maintain just enough state for a contiguous range as its boundaries move.
Prefix Sum
Precompute cumulative state so range totals or balanced prefixes are cheap.
Binary Search
Maintain an ordered search interval and discard half on each step.
Stack
Keep unresolved items in last-in-first-out order.
Fast & Slow Pointers
Advance pointers at different rates to reveal cycles or midpoints.
BFS
Explore a graph level by level with a queue.
DFS
Explore one branch fully before backtracking.
Topological Sort
Order directed dependencies while detecting cycles.
Union Find
Maintain connected components under repeated merges.
Backtracking
Choose, explore, and undo while pruning invalid partial solutions.
Heap Selection
Keep the best k candidates or next priority available incrementally.
Trie
Traverse character prefixes through a tree-shaped index.
1D DP
Build answers along one state dimension from previously solved positions.
2D DP
Track two changing dimensions such as grid position or paired prefixes.
Merge Intervals
Sort ranges, then combine or select them using endpoint relationships.
Monotonic Stack
Maintain candidates in increasing or decreasing order for nearest-boundary queries.
Greedy
Commit to a local choice backed by a global invariant or exchange argument.
Bit Manipulation
Use masks, shifts, and XOR identities to represent or transform state.
Loading Engineering Foundry…