Practice
Learn
← Quit
0 / 0 correct
Data Structures
Hard
1 of 572
How can a queue be built from two stacks with amortized O(1) operations?
A
It can't be done
B
Push onto an 'in' stack; when the 'out' stack is empty, pour all of 'in' into 'out' and pop from 'out'
C
Copy both stacks on every operation
D
Use one stack and reverse it each time