Problem 2202 · Medium

Maximize the Topmost Element After K Moves

Maximise the value at the top of a stack after exactly k moves that either remove the top or restore a removed value. The visual tracks the stack as items are removed and restored.

Open the interactive visualisation