2444. Count Subarrays With Fixed Bounds

Hard

2.1K

44

You are given an integer array `nums`

and two integers `minK`

and `maxK`

.

A **fixed-bound subarray** of `nums`

is a subarray that satisfies the following conditions:

- The
**minimum**value in the subarray is equal to`minK`

. - The
**maximum**value in the subarray is equal to`maxK`

.

Return *the number of fixed-bound subarrays*.

A **subarray** is a **contiguous** part of an array.

**Example 1:**

Input:nums = [1,3,5,2,7,5], minK = 1, maxK = 5Output:2Explanation:The fixed-bound subarrays are [1,3,5] and [1,3,5,2].

**Example 2:**

Input:nums = [1,1,1,1], minK = 1, maxK = 1Output:10Explanation:Every subarray of nums is a fixed-bound subarray. There are 10 possible subarrays.

**Constraints:**

`2 <= nums.length <= 10`

^{5}`1 <= nums[i], minK, maxK <= 10`

^{6}

Accepted

55.7K

Submissions

89.8K

Acceptance Rate

62.1%

Seen this question in a real interview before?

1/4

Yes

No

Discussion (0)

Related Topics

Copyright ©️ 2023 LeetCode All rights reserved