Sliding Window Maximum is a standard coding interview problem commonly featured on platforms like LeetCode (#239) and discussed in LinkedIn interview prep contexts with tags like Array, Queue, Sliding Window, Heap, and Monotonic Queue.[1][2][3]
You are given an integer array nums and an integer k. A sliding window of size k moves from the left to the right of the array. For each position of the window, return the maximum value within that window. The output is an array of these maximum values for each valid window position.[2][3][7][1]
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Explanation:
[1,3,-1]: max = 3[3,-1,-3]: max = 3[-1,-3,5]: max = 5[-3,5,3]: max = 5[5,3,6]: max = 6[3,6,7]: max = 7[3][2]Input: nums = [1,3,2,5,8,7], k = 3
Output: [3,5,8,8]
Explanation:
[1,3,2]: max = 3[3,2,5]: max = 5[2,5,8]: max = 8[5,8,7]: max = 8[3]Input: arr[] = [1, 2, 3, 1, 4, 5, 2, 3, 6], k = 3
Output: [3, 3, 4, 5, 5, 5, 6][7]
1 ≤ nums.length ≤ 10^5-10^4 ≤ nums[i] ≤ 10^41 ≤ k ≤ nums.length[2]