Number Of Subarrays With Bounded Maximum
easy
1. We have an array 'arr' of positive integers, and two positive integers left and right (left is smaller than right). 2. Return the number of (contiguous, non-empty) subarrays such that the value of the maximum array element in that subarray is at least left and at most right.
Constraints
1. left, right, and arr[i] will be an integer in the range [0, 10^9]. 2. The length of arr will be in the range of [1, 10000].
Format
Input
arr = [2, 1, 4, 3] left = 2 right = 3
Output
3 Explanation: There are three subarrays that meet the requirements: [2], [2, 1], [3].
Example
Sample Input
4
2 1 4 3
2
3
Sample Output
3