Given an array and a window size , return an array containing the maximum of each sliding window.
Example: , Windows: Maxes: Naive approach: for each window, scan all elements to find the max.
Time: . With a monotonic deque, you can do this in .
A classic problem
Given an array and a window size , return an array containing the maximum of each sliding window.
Example: , Windows: Maxes: Naive approach: for each window, scan all elements to find the max.
Time: . With a monotonic deque, you can do this in .