Stacks & Queues
Monotonic stack and deque — the two specialized container patterns that unlock 'next greater' and 'window max' problems.
A monotonic stack maintains its elements in strict order. By popping violators on every push, it lets us answer "what's the next greater / smaller element?" in amortized O(n). The deque variant adds left-side eviction for sliding-window aggregates.
Finished reading?
Mark it done to track your progress in Interview.
Intervals & Greedy
Sort by a custom key, then sweep. The pattern that collapses most "interval" and many "greedy" problems into a single linear pass.
Monotonic Stack / Deque
Maintain a stack or deque whose elements stay monotonic — pop violators on every push. The unlock for "next greater" and "sliding window max" problems.