Coding Challenge

Sliding Window Maximum

Hard
dequesliding-window

Return the maximum in every window of size k.

Given an integer array and a window size k, return the maximum value in each sliding window as it moves from left to right.

Examples

Input: nums = [1,3,-1,-3,5,3,6,7], k = 3

Output: [3,3,5,5,6,7]

Constraints

  • 1 <= k <= nums.length

Preparing your coding workspace...