Problem 2289 · Medium

Steps to Make Array Non-decreasing

Each element is removed after as many rounds as the longest chain of smaller predecessors before it; a monotonic stack finds it.

Open the interactive visualisation