Company: Algo university_11oct
Difficulty: medium
Flatten the Mountains Problem Description A ridge has N mountains standing in a row, numbered 1 to N from left to right. Mountain i has height H[i] . You may repeat the following move as many times as you like, including not at all: Pick a mountain i that is not at either end of the row (so 1 < i < N ) and that is not smaller than either of its neighbours , that is, H[i] >= H[i - 1] and H[i] >= H[i + 1] . Lower that mountain by exactly 1 , so H[i] becomes H[i] - 1 . Decide whether some sequence of moves can make every mountain in the row the same height. Complete the function solve with the following parameters: N : the number of mountains H : an array of N integers, where H[i - 1] is the height of mountain i It returns the string YES if all mountains can be made equal, and NO otherwise. The input holds several independent test cases; solve is called once per test case. Input Format The first line contains a single integer T , the number of test cases. The first line of eac