Problem 2874 · Medium
Sweep the middle index, keeping the largest value before it and the largest value after it.
Open the interactive visualisation