Back to problems

Design Circular Queue (Ring Buffer)

Object-Oriented Programming · Optiver · Medium

Requirements Build a queue with a fixed maximum size and support insertion, removal, inspection of both ends, and checks for whether the queue is empty or full. The interviewer will lead the discussion incrementally until you identify that the storage should wrap around, after which you will implement the data structure. Use the following API: When no element exists for Front or Rear, return -1. enQueue and deQueue should report whether their operation succeeded. Examples…

Checking your access…