Given an array of numbers, remove the elements according to following conditions
You might get the resulting array after removing the elements. Repeat the process until array remains unchanged. Return the number of steps in which the array remains unchanged.
Eg:
[6,3,1,8,9,4,3,2,8,9]
after 1st iteration we get
Step 1: [6,3,1,4,3,2] ---> [8,9] is removed since 1<8<9 && 2<8<9
Step 2: [6,3,1,3,2] ---> [4] is removed since 1<4
Step 3: [6,3,1,2] ---> [3] is removed since 1<3
Step 4: [6,3,1] ---> [2] is removed since 1<2
Answer: 4 (Total no. of steps are 4)