Design your implementation of the circular double-ended queue (deque).

Implement the MyCircularDeque class:


	MyCircularDeque(int k) Initializes the deque with a maximum size of k.
	boolean insertFront() Adds an item at the front of Deque. Returns true if the operation is successful, or false otherwise.
	boolean insertLast() Adds an item at the rear of Deque. Returns true if the operation is successful, or false otherwise.
	boolean deleteFront() Deletes an item from the front of Deque. Returns true if the operation is successful, or false otherwise.
	boolean deleteLast() Deletes an item from the rear of Deque. Returns true if the operation is successful, or false otherwise.
	int getFront() Returns the front item from the Deque. Returns -1 if the deque is empty.
	int getRear() Returns the last item from Deque. Returns -1 if the deque is empty.
	boolean isEmpty() Returns true if the deque is empty, or false otherwise.
	boolean isFull() Returns true if the deque is full, or false otherwise.


&nbsp;
Example 1:

Input
["MyCircularDeque", "insertLast", "insertLast", "insertFront", "insertFront", "getRear", "isFull", "deleteLast", "insertFront", "getFront"]
[[3], [1], [2], [3], [4], [], [], [], [4], []]
Output
[null, true, true, true, false, 2, true, true, true, 4]

Explanation
MyCircularDeque myCircularDeque = new MyCircularDeque(3);
myCircularDeque.insertLast(1);  // return True
myCircularDeque.insertLast(2);  // return True
myCircularDeque.insertFront(3); // return True
myCircularDeque.insertFront(4); // return False, the queue is full.
myCircularDeque.getRear();      // return 2
myCircularDeque.isFull();       // return True
myCircularDeque.deleteLast();   // return True
myCircularDeque.insertFront(4); // return True
myCircularDeque.getFront();     // return 4


&nbsp;
Constraints:


	1 &lt;= k &lt;= 1000
	0 &lt;= value &lt;= 1000
	At most 2000 calls will be made to insertFront, insertLast, deleteFront, deleteLast, getFront, getRear, isEmpty, isFull.


class MyCircularDeque {
public:
    
    deque<int> dq;
    
    int max_size;
    
    MyCircularDeque(int k) {
        
        max_size = k;  
    }
    
    bool insertFront(int value) {
        
        if(dq.size() < max_size)
        {
            dq.push_front(value);
            
            return true;
        }
        
        return false;
    }
    
    bool insertLast(int value) {
        
        if(dq.size() < max_size)
        {
            dq.push_back(value);
            
            return true;
        }
        
        return false;
    }
    
    bool deleteFront() {
        
        if(dq.size() > 0)
        {
            dq.pop_front();
            
            return true;
        }
        
        return false;
    }
    
    bool deleteLast() {
        
        if(dq.size() > 0)
        {
            dq.pop_back();
            
            return true;
        }
        
        return false;   
    }
    
    int getFront() {
        
        if(dq.size() > 0)
            return dq.front();
        
        return -1;
    }
    
    int getRear() {
        
        if(dq.size() > 0)
            return dq.back();
        
        return -1;
    }
    
    bool isEmpty() {
        
        return dq.empty();
    }
    
    bool isFull() {
        
        return dq.size() == max_size;
    }
};
class MyCircularDeque {
public:
    
    deque<int> dq;
    
    int max_size;
    
    MyCircularDeque(int k) {
        
        max_size = k;  
    }
    
    bool insertFront(int value) {
        
        if(dq.size() < max_size)
        {
            dq.push_front(value);
            
            return true;
        }
        
        return false;
    }
    
    bool insertLast(int value) {
        
        if(dq.size() < max_size)
        {
            dq.push_back(value);
            
            return true;
        }
        
        return false;
    }
    
    bool deleteFront() {
        
        if(dq.size() > 0)
        {
            dq.pop_front();
            
            return true;
        }
        
        return false;
    }
    
    bool deleteLast() {
        
        if(dq.size() > 0)
        {
            dq.pop_back();
            
            return true;
        }
        
        return false;   
    }
    
    int getFront() {
        
        if(dq.size() > 0)
            return dq.front();
        
        return -1;
    }
    
    int getRear() {
        
        if(dq.size() > 0)
            return dq.back();
        
        return -1;
    }
    
    bool isEmpty() {
        
        return dq.empty();
    }
    
    bool isFull() {
        
        return dq.size() == max_size;
    }
};
class MyCircularDeque {
public:

    deque<int> dq;

    int max_size;

    MyCircularDeque(int k) {

        max_size = k;
    }

    bool insertFront(int value) {

        if(dq.size() < max_size)
        {
            dq.push_front(value);

            return true;
        }

        return false;
    }

    bool insertLast(int value) {

        if(dq.size() < max_size)
        {
            dq.push_back(value);

            return true;
        }

        return false;
    }

    bool deleteFront() {

        if(dq.size() > 0)
        {
            dq.pop_front();

            return true;
        }

        return false;
    }

    bool deleteLast() {

        if(dq.size() > 0)
        {
            dq.pop_back();

            return true;
        }

        return false;
    }

    int getFront() {

        if(dq.size() > 0)
            return dq.front();

        return -1;
    }

    int getRear() {

        if(dq.size() > 0)
            return dq.back();

        return -1;
    }

    bool isEmpty() {

        return dq.empty();
    }

    bool isFull() {

        return dq.size() == max_size;
    }
};
class MyCircularDeque {
public:
    
    deque<int> dq;
    
    int max_size;
    
    MyCircularDeque(int k) {
        
        max_size = k;  
    }
    
    bool insertFront(int value) {
        
        if(dq.size() < max_size)
        {
            dq.push_front(value);
            
            return true;
        }
        
        return false;
    }
    
    bool insertLast(int value) {
        
        if(dq.size() < max_size)
        {
            dq.push_back(value);
            
            return true;
        }
        
        return false;
    }
    
    bool deleteFront() {
        
        if(dq.size() > 0)
        {
            dq.pop_front();
            
            return true;
        }
        
        return false;
    }
    
    bool deleteLast() {
        
        if(dq.size() > 0)
        {
            dq.pop_back();
            
            return true;
        }
        
        return false;   
    }
    
    int getFront() {
        
        if(dq.size() > 0)
            return dq.front();
        
        return -1;
    }
    
    int getRear() {
        
        if(dq.size() > 0)
            return dq.back();
        
        return -1;
    }
    
    bool isEmpty() {
        
        return dq.empty();
    }
    
    bool isFull() {
        
        return dq.size() == max_size;
    }
};
Design Circular Deque