C++ STL Deque
Basic Accuracy: 22.5% Submissions: 997 Points: 1

Implement different operations on a Deque i.e. adding an element in front and end, removing an element from front and end, sort the Deque, reverse the Deque, getting the size of the Deque. 

Input Format:
The first line of input contains an integer T denoting the no of test cases. For each test case, the first line of input contains an integer Q denoting the no of queries followed by Q space separated queries.
A query can be of the following types:
1 x (Adding an element in front of the deque and printing the deque)
2 x (Adding an element in last of the deque and printing the deque)
3 (Removing the element from the front of the deque and printing the deque)
4 (Removing the element from the last of the deque and printing the deque)
5 (Sorting the deque and printing the deque)
6 (Reversing the deque and printing the deque)
7 (Printing the deque)
8 (Returning the size of the deque)
9 (Printing the element that is in front of the deque)
10 (Printing the element that is in back of the deque)

Output Format:
For each test case, the output is according to the query Q performed and if the deque is empty the output is -1.

Your Task:
This is a function problem, so you only need to complete the provided functions.

Constraints:
1<=T<=100
1<=Q<=100

Example:
Input:

1
10
1 6
2 9
9
10
5
6
7
8
3
4
Output:

6 9 
6
9
6 9 
9 6 
9 6 
2

-1

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.