-
Notifications
You must be signed in to change notification settings - Fork 66
/
deque-implementation.cpp
39 lines (33 loc) · 864 Bytes
/
deque-implementation.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
31
32
33
34
35
36
37
38
39
// https://practice.geeksforgeeks.org/problems/deque-implementations/1/
/* Function to push element to front
* dq : dqueue in which element is to be pushed
* x : element to be pushed
*/
void push_back_pb(deque<int> &dq, int x){
// Your code here
dq.push_back(x);
}
/* Function to pop element from back
* dq : dqueue From which element is to be popped
*/
void pop_back_ppb(deque<int> &dq){
if(!dq.empty())
dq.pop_back();
}
/* Function to return element from front
* dq : dqueue from which element is to be returned
*/
int front_dq(deque<int> &dq){
if(!dq.empty())
return dq.front();
else
return -1;
}
/* Function to push element to front
* dq : dqueue in which element is to be pushed
* x : element to be pushed
*/
void push_front_pf(deque<int> &dq, int x){
// Your code here
dq.push_front(x);
}