 Timer is Running

Number of subarrays with maximum values in given range
##### Submissions: 1618   Accuracy: 25.58%   Difficulty: Medium   Marks: 4

Given an array of N elements and L and R, print the number of sub-arrays such that the value of the maximum array element in that subarray is at least L and at most R.

Input:
First line of input contains a single integer T denoting the number of test cases.
First line of every test case has three numbers N, L and R.
Second line of every test case contains N integers separated by space.

Output:
For each test case, print a single number in every new line denoting the number of sub-arrays with maximum in range L-R

Constraints:
1<=T<=100
1<=N<=10^4
1<=L<=R<=10^6

Example:
Input:

2

5 1 10

2 0 11 3 0

3 2 4

3 4 1
Output:
4

5
Explanation:
Test Case 1: the sub-arrays {2}, {2, 0}, {3} and {3, 0} have maximum in range 1-10.

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: Striver

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.