Course · Section 11: Working With Arrays · Lecture 149: Simple Array Methods
Design a fixed-size circular queue. Implement `MyCircularQueue`: - `new MyCircularQueue(k)` capacity k. - `enQueue(v)` / `deQueue()` return whether the operation succeeded. - `Front()` / `Rear()` return the front/rear value or `-1` if empty. - `isEmpty()` / `isFull()`.
+ 1 hidden test run on Submit.
A head pointer plus a count over a fixed array implements a circular buffer; modulo wraps indices. All operations are O(1).
Run your code to see results.