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.

hardikJain5 | 258 |

CodeBuddy | 250 |

bhatabhi554 | 232 |

Akkki111 | 197 |

clone | 174 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

SumitSingh27 | 1127 |

mazumderrohit8 | 1124 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4591 |

Quandray | 4444 |

Login to report an issue on this page.