Maximum of Fixed-Window Minima
Problem statement
For every contiguous subarray of exactly x values in nums, find its minimum value. Return the maximum among all of those window minima.
Windows may overlap. This asks for the maximum of minima, not the minimum of window maxima, and it does not ask for the maximum element directly unless x = 1.
Function
maxWindowMinimum(nums: int[], x: int) → intExamples
Example 1
nums = [2,5,4,6,1]x = 3return = 4The three windows have minima 2, 4 and 1. Their maximum is 4.
Example 2
nums = [-3,-1,-2]x = 2return = -2The minima are -3 and -2; the maximum is -2.
Example 3
nums = [7,4,9]x = 1return = 9A one-element window has its own value as its minimum.
Constraints
1 <= nums.length <= 1000.1 <= x <= nums.length.-10^9 <= nums[i] <= 10^9.