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.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

devsinghindra | 80 |

PiyushPandey4 | 614 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 443 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.