Queue Push & Pop
Basic Accuracy: 58.9% Submissions: 12999 Points: 1

Given an array arr[] of size N, enqueue the elements of the array into a queue and then dequeue them.

Example 1:

Input:
N = 5 
arr[] = 1 2 3 4 5 
Output: 
1 2 3 4 5

Example 2:

Input:
N = 7
arr[] = 1 6 43 1 2 0 5
Output:
1 6 43 1 2 0 5

Your Task:
You don't need to read any input. Your task is to complete the functions push() and _pop(). The function push() takes the array and its size as the input parameters and returns the queue formed, and the function _pop(), takes the queue as the input parameter and prints the elements of the queue.

 

Expected time complexity: O(n)

Expected space complexity: O(n)

 

Constraints:
1 <= Ai <= 107

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.


to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

Queue Push & Pop

Output Window