Double ended queue or Deque(part of C++ STL) are sequence containers with dynamic sizes that can be expanded or contracted on both ends (either its front or its back). The member functions of deque that are mainly used are:
-
Deque Template:
std::deque<value_type>
-
Declaration:
deque<int> mydeque; //Creates a double ended queue of deque of int type
-
Size
int length = mydeque.size(); //Gives the size of the deque
-
Push
mydeque.push_back(1); //Pushes element at the end mydeque.push_front(2); //Pushes element at the beginning
-
Pop
mydeque.pop_back(); //Pops element from the end mydeque.pop_front(); //Pops element from the beginning
-
Empty
mydeque.empty() //Returns a boolean value which tells whether the deque is empty or not
To know more about deque, click here
Given a set of arrays o