⚠️ Prerequisites
This phase assumes you've completed Phase 2 (Data Structures) and Phase 3 (Algorithms). Especially: Arrays, Stacks, Trees, Recursion, and Binary Search. These techniques BUILD on those foundations.
Two Pointers
Two indices traversing an array simultaneously. Eliminates the need for nested loops in many problems.
Sliding Window
Maintain a window that grows/shrinks based on conditions. Turns O(n²) subarray problems into O(n).
Monotonic Stack
A stack that maintains increasing or decreasing order. Solves "next greater element" type problems in O(n).
Tries (Prefix Trees)
A tree where each path spells a word. O(m) lookup for any word. Essential for autocomplete and word search.
Bit Manipulation
Operations directly on binary representations. XOR, AND, OR, shifts. Surprisingly elegant solutions.
Segment Trees & BIT
Range query and update in O(log n). Segment Tree for max/min/sum queries. Binary Indexed Tree for prefix sums.
Problem setters telegraph the technique in their phrasing. Train yourself to react to the exact words: