dsa · medium

Sliding Window Maximum

GreyOrangeQueueHeapDesign

nums and window k. Return the max of every contiguous window of length k.

Arguments

**Example**

`` Input: [1,3,-1,-3,5,3,6,7] 3 Output: [3,3,5,5,6,7] ``

Constraints

1 <= k <= nums.length <= 4*10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[1,3,-1,-3,5,3,6,7]
3

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

Open in the Dojo editor