Back
🧩
Patterns
Two pointers, binary search, heap, deque, bit tricks
Two Pointers
Opposite ends shrinking inward, or fast/slow on the same array
2 variants
Binary Search
The template that avoids off-by-one bugs — and why mid = lo + (hi-lo)//2
2 variants
Sliding Window
Expand right freely, shrink left when the window becomes invalid
2 variants
Priority Queue / Heap
Get the min or max in O(log n) — and how max-heap differs per language
2 variants
Deque (Double-Ended Queue)
Push/pop from both ends in O(1) — the backbone of BFS and sliding window max
2 variants
Bit Tricks
n & 1, n & (n-1), XOR patterns — O(1) operations that replace loops
1 variant
Stack
LIFO — push, pop, peek. Used for brackets, undo, monotonic patterns
2 variants
Prefix Sum
Subarray sum in O(1) after O(n) setup — the trick behind most subarray problems
2 variants