Problem 3738 · Medium

Longest Non-Decreasing Subarray After Replacing at Most One Element

Measure the non-decreasing run ending at each position and the run starting after it, then join the two runs across one replaced element.

Open the interactive visualisation