Company: Algo university_11oct
Difficulty: medium
Flatten the Mountains Problem Description You are given a range of mountain heights represented by an array H of length N . You can perform the following operation any number of times: Choose any mountain at position i such that 1 < i < N , and the height H i is not smaller than both of its neighbors — that is, H i ≥ H i-1 and H i ≥ H i+1 . Then, reduce the height of mountain i by 1. Your goal is to find out whether it is possible to make all mountains equal in height after performing the operation any number of times (possibly zero). Input Format The first line contains a single integer T — the number of test cases. Each test case consists of two lines: The first line contains an integer N — the number of mountains. The second line contains N integers H 1 , H 2 , ..., H N — the heights of the mountains. Output Format For each test case, print YES if it is possible to make all mountains equal, otherwise print NO . Examples Example 1: Input: 3 3 5 8 5 1 10 4 1 3 2 1 7 2 4 5