Design your implementation of the circular queue. A circular queue is a linear data structure in which the operations are performed based on FIFO principle and the last position is connected back to the first position to make a circle.
Input: MyCircularQueue q = new MyCircularQueue(3); q.enQueue(1); q.enQueue(2); q.enQueue(3); q.enQueue(4); // false; q.Rear(); // 3; q.isFull(); // true; q.deQueue(); // true; q.enQueue(4); // true; q.Rear(); // 4
Output: Circular Queue operations
Topics: queue, arrays
Asked by: Amazon, Microsoft, Meta, Google
Time complexity: O(1). Space complexity: O(k).