Tap here to switch tabs
Problem
Submissions

Problem: Steps to Make Array Non-decreasing

med
30 min
Try to solve the Steps to Make Array Non-decreasing problem.

Statement

You are given an integer array nums. In a single step, remove every element nums[i] for which nums[i - 1] > nums[i] holds, where 1≤i<1 \leq i < nums.length. All such removals in a step occur simultaneously.

Repeat this process until the array becomes non decreasing.

Return the number of steps required to make nums non decreasing.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Steps to Make Array Non-decreasing

med
30 min
Try to solve the Steps to Make Array Non-decreasing problem.

Statement

You are given an integer array nums. In a single step, remove every element nums[i] for which nums[i - 1] > nums[i] holds, where 1≤i<1 \leq i < nums.length. All such removals in a step occur simultaneously.

Repeat this process until the array becomes non decreasing.

Return the number of steps required to make nums non decreasing.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9