Queue Using Two Stacks
Medium
data-structures
Microsoft
Amazon
Implement a FIFO queue using two stacks (Python lists with append/pop). Support enqueue and dequeue operations.
Example
q = StackQueue()
q.enqueue(1)
q.enqueue(2)
q.dequeue() # => 1
q.dequeue() # => 2
Test Cases
Python Editor
Output
Click "Run" to see results...