Problems > Plausible Stack Story > Editorial

Plausible Stack Story — Solution & Editorial

Back to the Problem

Simulate: push values one by one, greedily popping while the stack top matches the next claimed pop. The story is plausible iff everything gets popped.

Complexity: O(N)