DiffPush Tier Stack and Queues · Implementation O(n) · O(k)
An ops dashboard samples a server farm's request counters once per second and reports the peak load over every rolling 10-second window. Recomputing each window from scratch would double-count nearly everything, so the sampler keeps a shortlist of only the candidates that could still become a window peak — evicting any older sample a newer one has overshadowed.
Input: An integer array nums and a window size k.
Output: Return the maximum of each window as it slides from left to right.
1 <= nums.length <= 10^51 <= k <= nums.length-10^4 <= nums[i] <= 10^4Input: {"nums":[1,3,-1,-3,5,3,6,7],"k":3}
Output: [3,3,5,5,6,7]
Each of the six windows reports its own peak as the frame advances one step at a time.
Input: {"nums":[9,8,7,6],"k":2}
Output: [9,8,7]
A strictly falling sequence: each window's peak is simply its first element.