Implement a ring buffer
Company: Akuna Capital
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Technical Screen
Implement a fixed-capacity circular buffer (ring buffer) supporting push, pop, peek, isEmpty, isFull, and size in O(
1) time using an array. Define and implement the behavior when pushing to a full buffer (either overwrite the oldest element or reject the push—choose and document). Provide iteration over current elements in logical order. Discuss how you would extend it to a thread-safe version with optional blocking push/pop using condition variables, and analyze time/space complexity.
Quick Answer: This question evaluates implementation skills for fixed-capacity circular buffers and competency in array-based data structures, including O(1) push/pop/peek/isEmpty/isFull/size operations and logical-order iteration.