Problem 3523 · Medium

Make Array Non-decreasing

Merge neighbouring segments into their maxima with a stack, so the segment maxima never decrease.

Open the interactive visualisation