java.lang.Object
g0701_0800.s0795_number_of_subarrays_with_bounded_maximum.Solution

public class Solution extends Object
795 - Number of Subarrays with Bounded Maximum.<p>Medium</p> <p>Given an integer array <code>nums</code> and two integers <code>left</code> and <code>right</code>, return <em>the number of contiguous non-empty <strong>subarrays</strong> such that the value of the maximum array element in that subarray is in the range</em> <code>[left, right]</code>.</p> <p>The test cases are generated so that the answer will fit in a <strong>32-bit</strong> integer.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [2,1,4,3], left = 2, right = 3</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> There are three subarrays that meet the requirements: [2], [2, 1], [3].</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [2,9,2,5,6], left = 2, right = 8</p> <p><strong>Output:</strong> 7</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 10<sup>5</sup></code></li> <li><code>0 <= nums[i] <= 10<sup>9</sup></code></li> <li><code>0 <= left <= right <= 10<sup>9</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numSubarrayBoundedMax

      public int numSubarrayBoundedMax(int[] nums, int left, int right)