Lets Make A Queue Using Array

easy
1. Implement a Queue using Array. 
 2. Your task is only to complete the functions push and pop.    
 3. push(x) which take one argument an integer 'x' to be pushed into the queue.
 4. pop() which returns a integer poped out from othe queue.
 5. The inputs will be:
  	 * For push(val) operation --> 1 val;
 	   Example push(1) --> 1 1
  	 * For pop() operation --> 2;

Input Format

First line contains 'N' number of operations to be performed. Second line contains N integers( For push(val) write 1 val, for pop() write 2)

Output Format

The output for each test case will be space separated integers having -1 if the queue is empty else the element poped out from the queue .

Constraints

1 <= Q <= 100
 1 <= x <= 100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
5
1 2 1 3 2 1 4 2
Output
2
3
Previous
Find The Next Larger Element
Next
Queue Using Linkedlist

Related Questions