102. Sliding Window Maximum
Hard
Given an array numeros and a size k, return the maximum value for each contiguous window of size k, from left to right. If k is invalid for the array, return an empty array.
Example 1
Input: numeros = [1, 3, -1, -3, 5, 3, 6, 7], k = 3
Output: [3, 3, 5, 5, 6, 7]
Example 2
Input: numeros = [4, 2, 8], k = 1
Output: [4, 2, 8]
Constraints
- 0 <= numeros.length <= 10^5
- 1 <= k <= numeros.length
ArraysSliding windowQueue
Saved in this browser
Caso 1
numeros =
[1,3,-1,-3,5,3,6,7]
k =
3
Expected =
[3,3,5,5,6,7]
Caso 2
numeros =
[4,2,8]
k =
1
Expected =
[4,2,8]
Run checks these 2 cases. Submit runs all 7, including hidden ones.