BETA

Difficulty Level: Easy

Submissions: 112 Accuracy:

48.21%

Mountain Subarray Problem (Function Problem)
     

We are given an array of integers and a range, we need to find whether the subarray which falls in this range has values in form of a mountain or not. All values of the subarray are said to be in form of a mountain if either all values are increasing or decreasing or first increasing and then decreasing. More formally a subarray [a1, a2, a3 … aN] is said to be in form of a mountain if there exist an integer K, 1 <= K <= N such that,
a1 <= a2 <= a3 .. <= aK >= a(K+1) >= a(K+2) …. >= aN

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N denoting the size of the array. The following line contains n space separated integers forming the array. The last line contains two space separated integers L and R denoting the range. 

Output:
Print "Yes" (without quotes) if the subarray is in mountain form.
Print "No" (without quotes) if the subarray is not in mountain form.

Constraints:
1<=T<=10^5
1<=N<=10^5
0<=L,R<=N

Example:
Input:

2
8
2 3 2 4 4 6 3 2
0 2
8
2 3 2 4 4 6 3 2
1 3

Output:
Yes
No

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

Contributor: Ayush Govil


					   
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.