Problem. Given nums and a window size k, return the maximum of each window nums[i : i + k] as the window
slides from left to right.
nums = [1, 3, -1, -3, 5, 3, 6, 7], k = 3 → [3, 3, 5, 5, 6, 7]
nums = [9, 8, 7], k = 1 → [9, 8, 7]
Module 04 slid windows with a running sum: adding the new value and subtracting the old one. The maximum can't be "subtracted": when the current maximum leaves the window, what's the next largest? Keeping that answer ready is the job of a monotonic deque.
ML context. Rolling maxima are everywhere in monitoring and signal processing: peak GPU memory over the last minute (lesson 6.10), the worst latency in a window, max-pooling in a 1D convolutional network (window k with stride 1), and the upper envelope of a noisy loss curve.