Sliding Window Maximum
Hard
LC #239
dequemonotonic queuefixed windowNot attempted yet
A window of size k slides over nums from left to
right, one step at a time. Return a list with the
maximum of each window, in order.
Example 1
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Example 2
Input: nums = [1], k = 1
Output: [1]
Example 3
Input: nums = [4,-2], k = 2
Output: [4]
Constraints
- 1 ≤ k ≤ len(nums) ≤ 10^5
- -10^5 ≤ nums[i] ≤ 10^5