Plausible Stack Story — Solution & Editorial
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)
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)