Practice Steps to Make Array Non-decreasing
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length. Return the number of steps performed until nums becomes a non-decreasing array.
Source: Steps to Make Array Non-decreasing on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [5,3,4,4,7,3,6,11,8,5,11]
Output
3
# Example 2
Input
nums = [4,5,7,7,13]
Output
0
Constraints
1 <= nums.length <= 10^5
1 <= nums[i] <= 10^9
Related LeetCode Problems
Practice more problems similar to Steps to Make Array Non-decreasing.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.