Problem 2297 · Medium

Jump Game VIII

Two monotonic stacks track the rising and falling jumps; each index takes the cheapest legal source.

Open the interactive visualisation