int front, rear, size, capacity;
/** Initialize your data structure here. Set the size of the deque to be k. */
MyCircularDeque(int k) : a(new int[k]), front(0), rear(-1),
/** Adds an item at the front of Deque. Return true if the operation is successful. */
bool insertFront(int value) {
a[front = capacity - 1] = value;
rear = (front + size - 1) % capacity;
/** Adds an item at the rear of Deque. Return true if the operation is successful. */
bool insertLast(int value) {
a[rear = (rear + 1) % capacity] = value;
/** Deletes an item from the front of Deque. Return true if the operation is successful. */
front = (front + 1) % capacity;
/** Deletes an item from the rear of Deque. Return true if the operation is successful. */
/** Get the front item from the deque. */
return isEmpty() ? -1 : a[front];
/** Get the last item from the deque. */
return isEmpty() ? -1 : a[rear];
/** Checks whether the circular deque is empty or not. */
/** Checks whether the circular deque is full or not. */