Given an array of integers and a window size, find the maximum value in each window of the given size as it slides through the array from left to right.
Explanation: The windows are [4, 2, 9], [2, 9, 7], [9, 7, 5], [7, 5, 3], [5, 3, 1] and their respective maxima are 9, 9, 7, 5, 3.
Explanation: The windows are [1, 3], [3, 5], [5, 2], [2, 6], [6, 4] and their respective maxima are 3, 5, 5, 6, 6.
Maximum in each window using deque
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak