239. Sliding Window Maximum

Practice Sliding Window Maximum for free on NudgeCode: Hard, Sliding Window pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

A window of width k starts at the left end of nums and moves right one position at a time until it reaches the right end. Return the largest value inside the window at each position.

Example

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

Constraints