← 返回 optiver 的题目列表Design Circular Queue (Ring Buffer)
类型:qbank
A guided phone-screen coding problem equivalent to LeetCode 622: implement a fixed-capacity circular queue. The interviewer leads you to recognize that the scenario needs a ring-buffer design, then has you implement it.
Requirements
Implement a fixed-capacity circular queue supporting the standard operations (enqueue, dequeue, front/rear, isEmpty, isFull).
The interviewer guides you step by step until you realize a circular-buffer layout is required, then asks you to code it.
Notes
Equivalent to LeetCode 622 (Design Circular Queue), per the candidate's account.
The signal is recognizing the ring-buffer pattern from the prompt and getting the wrap-around index arithmetic and full/empty distinction right.
Preparation
Implement a ring buffer with head/tail pointers and a size counter (or a reserved-empty-slot scheme) and test the wrap-around and full/empty edges.