Micro and Queue | HackerEarth
Micro just purchased a queue and wants to perform N operations on the queue. The operations are of the following type:
: Enqueue x in the queue and print the new size of the queue.
D: Dequeue from the queue and print the element that is deleted and the new size of the queue separated by space. If there is no element in the queue then print 1 in place of the deleted element.
Since Micro is new with a queue data structure, he needs your help.
Input:
First-line consists of a single integer denoting N
Each of the following N lines contains one of the operations as described above.
Output:
For each enqueues operation print the new size of the queue. And for each dequeue operation, print two integers deleted element (1, if the queue is empty) and the new size of the queue.
Constraints:
: Enqueue x in the queue and print the new size of the queue.
D: Dequeue from the queue and print the element that is deleted and the new size of the queue separated by space. If there is no element in the queue then print 1 in place of the deleted element.
Since Micro is new with a queue data structure, he needs your help.
Input:
First-line consists of a single integer denoting N
Each of the following N lines contains one of the operations as described above.
Output:
For each enqueues operation print the new size of the queue. And for each dequeue operation, print two integers deleted element (1, if the queue is empty) and the new size of the queue.
Constraints:
Input
5
E 2
D
D
E 3
D
E 2
D
D
E 3
D
Output
5
E 2
D
D
E 3
D
Comments
Post a Comment