Implement Queue using Stacks
Easy
Stacks
Stack
Queue
Design
Implement a FIFO queue using two stacks. Process push/pop/peek/empty commands.
Constraints
Commands ≤ 100
Examples
Example 1:
Input: push 1
push 2
peek
pop
empty
Output: 1
1
false
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console