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.
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.