Problem 2420 · Medium

Find All Good Indices

Precompute how long each non-increasing run ends at a position and how long each non-decreasing run starts there, then check both sides of every index.

Open the interactive visualisation