Basic push and pop
Input
run_ops([['push', 1], ['push', 2], ['pop'], ['pop'], ['empty']])
Output
[2, 1, True]
Push 1 then 2. pop returns 2 then 1. After both pops the stack is empty.
Full lesson preview
Implement a LIFO stack using two FIFO queues. Support push, pop, top, and empty operations.
Problem statement
Task
Examples
Input
run_ops([['push', 1], ['push', 2], ['pop'], ['pop'], ['empty']])
Output
[2, 1, True]
Push 1 then 2. pop returns 2 then 1. After both pops the stack is empty.
Input format
Output format
Constraints
Samples
Input
run_ops([['push', 5], ['top'], ['push', 6], ['top'], ['pop']])
Output
[5, 6, 6]
After pushing 5, top is 5. After pushing 6, top is 6. pop removes and returns 6.