Why it matters
Sliding window aggregation is core streaming op. Understanding shapes efficient stream.
Advertisement
The architecture
Deque of indices, monotonic increasing values.
Push new: pop tail while > new.
Pop head if out of window.
Advertisement
How it works end to end
Deque maintains monotonic values.
Head is current min.
Amortized O(1) per element.
Total O(n).