Problem · Array
Minimum of Fixed-Window Maxima
Learn this problemProblem statement
You are given an integer array nums and an integer k. Consider every contiguous subarray of exactly k elements.
Compute the maximum value in each such window, then return the minimum among all of those window maxima.
Function
minimumWindowMaximum(nums: int[], k: int) → intExamples
Example 1
nums = [1,3,2,5,1,4]k = 3return = 3The four window maxima are 3, 5, 5, and 5. Their minimum is 3.
Example 2
nums = [-4,-2,-7,-3]k = 2return = -3The window maxima are -2, -2, and -3. The minimum is -3.
Example 3
nums = [5,1,5]k = 1return = 1With k = 1, every element is its own window maximum. The smallest of 5, 1, and 5 is 1.
Constraints
1 <= nums.length.1 <= k <= nums.length.- Every value in
numsis a signed32-bit integer.