class MyCircularQueue {
public:
vector<int> q;
int hh,tt,qsize;
MyCircularQueue(int k) {
q.resize(k);
hh = -1,tt = -1,qsize = k;
}
bool enQueue(int value) {
if(isFull()) return false;
if(isEmpty()) hh = 0;
tt = (tt+1)%qsize;
q[tt] = value;
return true;
}
bool deQueue() {
if(isEmpty()) return false;
if(hh == tt){
hh = -1;
tt = -1;
return true;
}
hh = (hh+1)%qsize;
return true;
}
int Front() {
if(isEmpty()) return -1;
return q[hh];
}
int Rear() {
if(isEmpty()) return -1;
return q[tt];
}
bool isEmpty() {
if(hh == -1) return true;
return false;
}
bool isFull() {
if((tt+1)%qsize == hh) return true;
return false;
}
};