Your question is Implement a Circular Buffer. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement a circular buffer.
Asked in the coding stage for the Meta Reality Labs Embedded SW Engineer, Firmware interview, in the same round as the memcpy question. Reported follow-ups included “why” and “what” questions about implementation choices.
Implement circular_buffer(capacity, operations). Each operation is an array: ["enqueue", value], ["dequeue"], ["peek"], ["is_empty"], or ["is_full"]. Return one result per operation. enqueue returns true or false, dequeue and peek return a value or null, and status operations return booleans. The buffer must preserve FIFO order and reuse storage after wraparound.
def circular_buffer(capacity, operations):