Implement Queue
Easyjavapythonccppjavascript
Implement a queue that supports enqueue, dequeue, front and empty operations, processing a stream of operations.
Input Format
The first line contains an integer Q. Each of the next Q lines is one of: enqueue X — add integer X to the back dequeue — remove and return the front element front — return the front element without removing it empty — return whether the queue is empty
Output Format
For each dequeue or front, print the element (or -1 if the queue is empty). For each empty, print 1 if empty, otherwise 0. One value per line.
Example 1
Input
4 enqueue 10 enqueue 20 front dequeue
Output
10 10
Explanation: Queues follow First In, First Out order.
- 1 <= Q <= 100000
- -1000000000 <= X <= 1000000000