622. Design Circular Queue

Practice Design Circular Queue for free on NudgeCode: Medium, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Design a fixed-size FIFO queue backed by a circular buffer of capacity k, so freed slots at the front get reused.

Do not use a built-in queue type.

Each test is a list of operations and their arguments; the expected output lists what each call returns (null for the constructor and for calls that return nothing).

Example

["MyCircularQueue","enQueue","enQueue","enQueue","enQueue","Rear","isFull","deQueue","enQueue","Rear"]
[[3],[1],[2],[3],[4],[],[],[],[4],[]]
->  [null,true,true,true,false,3,true,true,true,4]

Constraints