1 x (a query of this type means pushing 'x' into the queue)
2 (a query of this type means to pop an element from the queue and print the popped element)
Examples
Example 1
Example 1
Input: Q = 5, Queries = 1 2 1 3 2 1 4 2
Output: 2 3
Explanation: n the first testcase. 1 2 the queue will be {2}. 1 3 the queue will be {2 3}. 2 poped element will be 2 the queue will be {3}. 1 4 the queue will be {3 4}. 2 poped element will be 3.
Hints
Hint 1
Expected Time Complexity: O(1).
Hint 2
Expected Auxiliary Space: O(1).
Constraints
1 <= Q <= 100
1 <= x <= 100
Companies
MicrosoftAppleWalmart
Topics
Queue
Track your submissions
Please log in to review your progress and explore code submissions from other participants.
Unlock the full solution
Please log in to access detailed answers and explanations.
Join the discussion
Please log in to join conversations with other participants.
Solution.csC#JavaPythonC++Javascript
1
2
3
4
5
6
7
8
9
10
Unlock the code editor
Sign in to write, run, and submit your solution against the full test suite.