Problem 3362 · Medium

Zero Array Transformation III

Sweep left to right, using the queries that reach each index with the farthest right ends first, and keep the rest.

Open the interactive visualisation