Class Solution
java.lang.Object
g2401_2500.s2444_count_subarrays_with_fixed_bounds.Solution
2444 - Count Subarrays With Fixed Bounds.<p>Hard</p>
<p>You are given an integer array <code>nums</code> and two integers <code>minK</code> and <code>maxK</code>.</p>
<p>A <strong>fixed-bound subarray</strong> of <code>nums</code> is a subarray that satisfies the following conditions:</p>
<ul>
<li>The <strong>minimum</strong> value in the subarray is equal to <code>minK</code>.</li>
<li>The <strong>maximum</strong> value in the subarray is equal to <code>maxK</code>.</li>
</ul>
<p>Return <em>the <strong>number</strong> of fixed-bound subarrays</em>.</p>
<p>A <strong>subarray</strong> is a <strong>contiguous</strong> part of an array.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,3,5,2,7,5], minK = 1, maxK = 5</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> The fixed-bound subarrays are [1,3,5] and [1,3,5,2].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,1,1,1], minK = 1, maxK = 1</p>
<p><strong>Output:</strong> 10</p>
<p><strong>Explanation:</strong> Every subarray of nums is a fixed-bound subarray. There are 10 possible subarrays.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>1 <= nums[i], minK, maxK <= 10<sup>6</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
countSubarrays
public long countSubarrays(int[] nums, int minK, int maxK)
-