Optiver software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for Optiver.
def __init__(self, capacity: int) -> None: Initializes the circular buffer queue with a given capacity.def enqueue(self, item: Any) -> None: Adds an item to the queue. Raises an error if the queue is full.def dequeue(self) -> Any: Removes and returns the item at the front of the queue. Raises an error if the queue is empty.def is_empty(self) -> bool: Returns True if the queue is empty, otherwise False.def is_full(self) -> bool: Returns True if the queue is full, otherwise False.def clear(self) -> None: Clears all items from the queue.CircularBufferQueue(3) followed by enqueue(1), enqueue(2), enqueue(3), dequeue() → Output: 1 → Explanation: The queue initially contains [1,2,3]. After dequeuing, the first item is removed.Example 2: CircularBufferQueue(2) followed by enqueue(10), enqueue(20), enqueue(30) → Output: Error → Explanation: The third enqueue operation fails because the queue is full.Constraints:capacity (1 <= capacity <= 10000)10000.def __init__(self, capacity: int) -> None: Initializes the circular buffer with a given capacity.def enqueue(self, value: Any) -> None: Adds an element to the buffer, raises an exception if the buffer is full.def dequeue(self) -> Any: Removes and returns the oldest element, raises an exception if the buffer is empty.def is_full(self) -> bool: Returns True if the buffer is full, otherwise False.def is_empty(self) -> bool: Returns True if the buffer is empty, otherwise False.cb = CircularBuffer(3); cb.enqueue(1); cb.enqueue(2); cb.enqueue(3) → Output: None, Explanation: The buffer contains [1, 2, 3].cb.dequeue() → Output: 1, Explanation: Removes 1, buffer now contains [2, 3].Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free