Given an integer array nums and an integer k, return the maximum value in every contiguous subarray of size k. Example: Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 Output: [3,3,5,5,6,7] Explanation: The maximum is tracked for each sliding window. Pattern focus: Monotonic Deque for Sliding Window Extremes.
nums = array of integers, k = window size
maximum of each window of size k
Example 1:
Input:
nums = [1,3,-1,-3,5,3,6,7] k = 3
Output:
[3,3,5,5,6,7]
Explanation:
Keep only useful candidates in a decreasing deque.
Example 2:
Input:
nums = [9,11] k = 2
Output:
[11]
Explanation:
A single window returns one maximum.