You are given an array of integers nums and a sliding window of size k moving from the left of the array to the right, one position at a time. Return the max sliding window — an array of the maximum value in each window position.
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Topics: arrays, sliding-window, heap
Asked by: Amazon, Google, Meta, Microsoft, Bloomberg
Time complexity: O(n). Space complexity: O(k).