Code RoomCircular queue operations
MediumPrep Room Coding #322

Circular queue operations

CodingAlgorithms & data structuresMid–Senior~30 min

Implement and exercise a fixed-capacity circular queue (ring buffer). You are given a capacity and a list of operations; each operation is a list whose first element is the op name. Supported ops: ['enQueue', x] inserts x at the rear and returns True, or False if full; ['deQueue'] removes the front and returns True, or False if empty; ['Front'] returns the front value or -1 if empty; ['Rear'] returns the rear value or -1 if empty; ['isEmpty'] returns a bool; ['isFull'] returns a bool. Return the list of results, one per operation, in order. There are 1 to 3000 operations and capacity is between 1 and 1000.

Implement
run_circular_queue(capacity: int, ops: list[list]) → list
Examples
in[3,[["enQueue",1],["enQueue",2],["enQueue",3],["enQueue",4],["Rear"],["isFull"],["deQueue"],["enQueue",4],["Rear"]]]out[true,true,true,false,3,true,true,true,4]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 30 min
InputExpectedGot
[3,[["enQueue",1],["enQueue",2],["enQueue",3],["enQueue",4],["Rear"],["isFull"],["deQueue"],["enQueue",4],["Rear"]]][true,true,true,false,3,true,true,true,4]not run yetsample