Hard · Sliding Window
Sliding Window Maximum
Given an integer array nums and a window size k with 1 ≤ k ≤ nums.length, return the maximum of every contiguous window of k elements, in order from left to right.
Examples
Example 1
[1,3,-1,-3,5,3], k=3Output: [3, 3, 5, 5]
Example 2
[9,11,8,5,7], k=2Output: [11, 11, 8, 7]
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.