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

Yes

No

Author: Ayush Govil 1

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.

Vagesh Verma | 166 |

vamsikrishna55 | 162 |

UrGuru | 150 |

abducodes | 145 |

adithya_99 | 119 |

abducodes | 701 |

harshtyagi36 | 326 |

sandipbhaumik | 291 |

Akhil varma | 267 |

arpit_anshuman | 262 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.