Week 2 · Day 10 of 42

Sliding Window: Monotonic Queue for Max/Min

If you need the max or min inside a sliding window efficiently — use a monotonic deque. The deque stores indices and maintains decreasing order (for max) or increasing order (for min).

Checking access

Spotted a mistake on this page?

Wrong formula, broken animation or confusing wording. Tell us and we will fix it.