So I had this question in one of my past interviews and can't figure out a solution for this.
Question : We have an array. In one step we can find all elements that are greater than the element to their left, or all A[i] such that A[i] > A[i-1], and then delete them from the array. The question is how many steps will it take to reach a state where no more elements can be removed.
Example :
3 6 9 8 => 3 8 => 3
So it took 2 steps in this case.
I can figure that at the end the only elements remaining will be those less than or equal to A[0].
I also tried to use LIS or similar methods but cannot get a correct solution and understanding. Can anyone help me with this ?