forked from anubhav100rao/codeplus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deque_stl.cpp
30 lines (21 loc) · 931 Bytes
/
deque_stl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>
using namespace std;
int main() {
// deque doubly ended queue
// functions
// deque.push_back(el) push el in back of deque
// deque.push_front(el) push el in front of deque
// deque.pop_back() removes the last element of deque
// deque.pop_front() removes the front element of deque
// deque.front() returns the front element of deque
// deque.back() returns the back element of queue
deque<int>dq;
vector<int>elements = {1, 2, 3, 4, 5, 6};
for(int i: elements)
dq.push_back(i);
cout << dq.front() << " " << dq.back() << "\n"; // your turn guess the output 🚀🚀
dq.pop_back();
cout << dq.front() << " " << dq.back() << "\n"; // your turn guess the output 🚀🚀
dq.pop_front();
cout << dq.front() << " " << dq.back() << "\n"; // your turn guess the output 🚀🚀
}