Count Subarrays With Fixed Bounds

You are given an integer array nums and two integers minK and maxK. A fixed-bound subarray of nums is a subarray where the minimum value is equal to minK and the maximum value is equal to maxK. Return the number of fixed-bound subarrays. A subarray is a contiguous part of an array.

Constraints

  • 2 <= nums.length <= 10^5
  • 1 <= nums[i], minK, maxK <= 10^6
Saving… · 3 lines
class Solution:
def countSubarraysWithFixedBounds(self, nums, minK, maxK) -> int:

Console

Click Run to execute sample tests.