Skip to content
C

Queue Using Two Stacks

Mediumjavapythonccppjavascript

Implement a queue using only two stacks, so that operations still behave in First In, First Out order.

Input Format

The first line contains an integer Q. Each of the next Q lines is one of: enqueue X, dequeue, front, empty.

Output Format

For each dequeue or front, print the element (or -1 if empty). For each empty, print 1 if empty, otherwise 0. One value per line.

Input (stdin)

Output

Run your code to see output here...