Problem 3542 · Medium

Minimum Operations to Convert All Elements to Zero

A monotonic stack of distinct positive values counts the operations, because each new value needs one operation unless it is already covered.

Open the interactive visualisation