C++ STL Deque
Submissions: 569   Accuracy:

24.28%

  Difficulty: Basic   Marks: 1

Implement different operation 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:
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:
For each test case, the output is according to the query Q performed and if the deque is empty the output is -1.

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

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vanshika
Author: Vanshika_pec


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.