1class MyCircularQueue {
2 constructor(k) {
3 this.arr = new Array(k).fill(null);
4 this.front = 0; this.rear = -1; this.size = 0;
5 }
6 enQueue(value) {
7 if (this.isFull()) return false;
8 this.rear = (this.rear + 1) % this.arr.length;
9 this.arr[this.rear] = value; this.size++;
10 return true;
11 }
12 deQueue() {
13 if (this.isEmpty()) return false;
14 this.arr[this.front] = null;
15 this.front = (this.front + 1) % this.arr.length;
16 this.size--; return true;
17 }
18 isEmpty() { return this.size === 0; }
19 isFull() { return this.size === this.arr.length; }
20}