Steps to make array monotonic
Leetcode 2289. Steps to Make Array Non-decreasing problem: Given a 0-indexed integer array \(A\). In one step, remove all elements \(A[i]\) where \(A[i]\) is less than its left neighbor, return the number of steps performed until nums becomes a non-decreasing array. Input: \([5,3,4,4,7,3,6,11,8,5,11]\) Output: 3Explanation: The following are the steps performed: Step 1: \([5,3,4,4,7,3,6,11,8,5,11]\) ==> \([5,4,4,7,6,11,11]\) Step 2: \([5,4,4,7,6,11,11]\) ==> \([5,4,7,11,11]\) Step 3: \([5,4,7,11,11]\) ==> \([5,7,11,11]\) \([5,7,11,11]\) is a non-decreasing array. Therefore, we return 3.My solutionMy solution is very straightforward. The steps are:Number of steps ct=:0; record the indice of...