Sliding Window Maximum
Hard
Topics
Given an array nums and a window size k, the window slides from left to right one position at a time. Return an array of the maximum value in each window.
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]
Constraints
- 1 <= nums.length <= 10^5
- 1 <= k <= nums.length
Run ⌘' · Submit ⌘⏎