Fixed-Capacity Ring Buffer Queue

Asked at Optiver · Coding Questions · Difficulty: Medium · Last asked Jul 15, 2026

Implement a queue with a fixed capacity on top of a fixed-size array. When the end of the array is reached, positions wrap around to the start so that slots freed at the front are reused (a ring buffer). Elements leave in the order they entered, and the queue never grows beyond its capacity.

Loading the problem…