FastPrepMaximum of Window Minimums

Maximum of Window Minimums

Oracle logoOracle● MediumFULLTIMEPHONE SCREEN
Learn

Problem statement

Given an integer array nums and an integer windowSize, consider every contiguous subarray of length windowSize.

Find the minimum value in each window and return the maximum among those window minimums.

Function

maximumOfWindowMinimums(nums: int[], windowSize: int) → int

Examples

Example 1

nums = [1,3,-1,5,3,6]windowSize = 3return = 3

The window minimums are -1, -1, -1, and 3; their maximum is 3.

Example 2

nums = [-4,-2,-5]windowSize = 1return = -2

With window size 1, each element is its own minimum, so the maximum is -2.

Constraints

  • 1 <= nums.length <= 200000
  • -10^9 <= nums[i] <= 10^9
  • 1 <= windowSize <= nums.length

More Oracle problems

See Oracle hiring insights
public int maximumOfWindowMinimums(int[] nums, int windowSize) {
    // Write your code here.
}
nums[1,3,-1,5,3,6]
windowSize3
expected3
Checking account…