A weather station logs one temperature per hour in temps. For every block of k consecutive hours, report the highest temperature in that block. Return the list of peaks, one per window, from left to right.
Examples
Input: temps = [12, 15, 11, 9, 14, 16, 10, 8], k = 3
Output: [15, 15, 14, 16, 16, 16]
Input: temps = [-4], k = 1
Output: [-4]
Constraints
1 <= k <= len(temps) <= 10**5-10**9 <= temps[i] <= 10**9- Target complexity: O(n) time. Calling
maxon every window is O(n·k) and too slow for the largest tests.
Goals
- Maintain a deque of candidate indices in decreasing value order
- Evict indices that leave the window and values dominated by a newer element