Approach hintTry it first, then revealHide
Push into an input stack and pop from an output stack, moving everything from input to output only when output is empty. Each element moves at most once, so operations are amortised O(1).
Push into an input stack and pop from an output stack, moving everything from input to output only when output is empty. Each element moves at most once, so operations are amortised O(1).