Problem 3834 · Medium
Use a stack: each new value merges with equal tops, and a merge can cascade to the left.
Open the interactive visualisation