BETA

Difficulty Level: Medium

Submissions: 197 Accuracy:

14.21%

Number of subarrays with maximum values in given range
     

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

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.