Optiver logo

Optiver Software Engineer Interview Questions

12 practice questions for Optiver Software Engineer interviews

Optiver software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Hard Verified Question #1

1. Capital Gains Tax Calculator


Category: String coding problem
You are given a chronologically sorted list of stock transactions. Each transaction is a list of strings in the format `[<timestamp>, <type>,...
Input: Array of strings
Output: Computed result
Want to practise this one?
Create a free account to open the full question and practise Optiver questions with AI.
Sign up free
coding Hard Verified Question #2

2. Plane Cargo Allocator


Category: Algorithm coding problem
A shipping terminal receives orders and must route cargo to available docks. Each dock has a fixed dispatch time and a remaining load capacity. An...
Input: List
Output: Computed result
coding Hard Verified Question #3

3. [CodeSignal] Fibonacci Storage System


Category: Graph coding problem
A research facility stores artifacts in underground vaults. Each vault has multiple tiers, indexed from 0 (deepest) upward. The capacity of each tier...
Input: Graph (nodes and edges)
Output: Computed result
coding Hard Verified Question #4

4. [CodeSignal] Fixed Price Purchase Optimizer


Category: Algorithm coding problem
A procurement team must purchase n identical components one at a time. For each component, the quoted market price is drawn independently and...
Input: Given input
Output: Integer
coding Medium Verified Question #5

5. [CodeSignal] Portfolio Path Counter


Category: Algorithm coding problem
A warehouse manager starts with initial units of inventory. In one operation, the manager can either restock one unit (increase inventory by 1) or...
Input: Number(s)
Output: Integer
coding Hard heap #1

1. [Heap] — Schedule trading messages without violating per-session ordering


Background
Optiver's trading infrastructure must coordinate outbound exchange messages while preserving ordering within each exchange session. This exercise models a deterministic scheduler that balances message urgency and release times without allowing a later message to overtake an earlier message in the same session.
Problem statement
Implement a single-threaded MessageScheduler. Each message has a globally unique identifier, a session identifier, a release timestamp, and an integer priority.
Messages within a session form a FIFO queue in enqueue order. Only the first non-cancelled, undispatched message in each session may compete for dispatch. Consequently, a message whose release time has passed can still be blocked by an earlier message in its session.
The scheduler's clock initially equals 0. Calling dispatch(now, limit) sets its clock to now; dispatch timestamps must be nondecreasing. Enqueueing and cancellation do not advance the clock.
For each slot in a dispatch call:
  • Consider the head message of every nonempty session whose release_time <= now.

  • Choose the message with the highest priority.

  • Break priority ties by earlier release time, then by earlier global enqueue order.

  • Remove and return the chosen message. Its session's next message immediately becomes the head and can compete for the next slot in the same call.


Stop after returning limit messages or when no session head is eligible. Dispatch does not advance time beyond now, and there is no service duration.
Cancellation removes a pending message logically. If it was a session head, the next non-cancelled message immediately becomes the head. Cancelling an unknown, already-cancelled, or already-dispatched identifier returns false.
Support up to 200,000 operations efficiently. Do not scan every session on each dispatch or search linearly through a session to cancel a message.
Function or class signature
  • MessageScheduler() — initialize an empty scheduler.

  • enqueue(message_id: str, session_id: str, release_time: int, priority: int) -> None

  • cancel(message_id: str) -> bool

  • dispatch(now: int, limit: int) -> list[str]


Example 1:
Input, on a fresh scheduler:
[
  ["enqueue", "A1", "alpha", 10, 1],
  ["enqueue", "A2", "alpha", 0, 100],
  ["enqueue", "B1", "beta", 0, 5],
  ["dispatch", 0, 10],
  ["dispatch", 9, 10],
  ["dispatch", 10, 1],
  ["dispatch", 10, 10]
]
Output, one result per operation:
[null, null, null, ["B1"], [], ["A1"], ["A2"]]
Explanation: At time 0, A2 is blocked by A1, despite having priority 100 and release time 0. Only B1 can run. At time 9, A1 is still unreleased. The first call at time 10 dispatches A1 and reaches its limit; the next call dispatches A2.
Example 2:
Input, on a fresh scheduler:
[
  ["enqueue", "X1", "x", 20, 9],
  ["enqueue", "X2", "x", 5, 4],
  ["enqueue", "Y1", "y", 5, 4],
  ["enqueue", "Z1", "z", 3, 4],
  ["cancel", "X1"],
  ["dispatch", 5, 2],
  ["cancel", "X1"],
  ["dispatch", 5, 2]
]
Output, one result per operation:
[null, null, null, null, true, ["Z1", "X2"], false, ["Y1"]]
Explanation: Cancelling X1 exposes X2. At time 5, the three session heads all have priority 4. Z1 wins first because its release time is 3; X2 wins next because it was enqueued before Y1, and both have release time 5. A second cancellation of X1 returns false.
Constraints:
  • At most 200,000 total method calls and at most 200,000 enqueued messages.

  • Message and session identifiers are nonempty strings of at most 32 ASCII characters.

  • Message identifiers are unique across the entire lifetime of a scheduler, including after cancellation or dispatch.

  • 0 <= release_time, now <= 10^18; -10^9 <= priority <= 10^9.

  • 0 <= limit <= 200,000; successive dispatch timestamps are nondecreasing.

  • Release times need not increase within a session, and a newly enqueued message may already be released.

  • All calls are single-threaded. Inputs satisfy the stated constraints.


Follow-up:
The scheduler runs indefinitely, but only P messages are pending at any moment. How would you guarantee O(P + 1) retained space after every operation, while preserving efficient cancellation and dispatch even when cancelled messages have release times far in the future?
Want to practise this one?
Create a free account to open the full question and practise Optiver questions with AI.
Sign up free
coding Medium stack queue #2

2. CODING — Implement a circular buffer queue

Background: In trading systems like those at Optiver, managing data streams effectively is crucial for performance. A circular buffer queue is an efficient way to handle a fixed-size buffer that can be filled and read from simultaneously.
Problem statement: Implement a class CircularBufferQueue with methods to enqueue and dequeue elements in a circular manner. The enqueue method should add an element, and if the queue is full, it should overwrite the oldest element. The dequeue method should remove and return the front element.
Function/class signature:
  • def __init__(self, capacity: int) -> None:

  • def enqueue(self, value: Any) -> None:

  • def dequeue(self) -> Any:

  • def is_empty(self) -> bool:

  • def is_full(self) -> bool:

Example 1: Input: cbq = CircularBufferQueue(3) cbq.enqueue(1) cbq.enqueue(2) cbq.enqueue(3) cbq.enqueue(4) out = cbq.dequeue()
Output: 1
Explanation: After adding four elements, the first element (1) has been overwritten by the last enqueued element (4), thus when dequeuing it returns 1.
Example 2: Input: cbq.enqueue(5) out = cbq.dequeue()
Output: 2
Constraints:
  • Capacity of the buffer (1 <= capacity <= 1000)

  • Number of operations will not exceed 10^6

  • Values can be any type.

coding Medium stack queue #3

3. CODING — Implement a Circular Queue

Background: In the context of high-frequency trading systems at Optiver, efficient handling of orders and market data is crucial. A circular queue provides an efficient way to manage this data without wasting space.
Problem statement: Design a CircularQueue class that implements a circular queue with basic operations such as enqueue, dequeue, and is_empty. The queue should be of fixed size, and once it reaches its maximum capacity, new items should overwrite the oldest items.
Function/class signature:
  • def __init__(self, size: int) -> None:

  • def enqueue(self, item: Any) -> None:

  • def dequeue(self) -> Any:

  • def is_empty(self) -> bool:

Example 1:
Input:
queue = CircularQueue(3)  
queue.enqueue(1)  
queue.enqueue(2)  
queue.enqueue(3)  
queue.enqueue(4)  # This should overwrite 1

Output:
queue.dequeue() returns 2
Example 2:
Input:
queue = CircularQueue(2)  
queue.enqueue(5)  
queue.enqueue(6)  
queue.dequeue()  
queue.enqueue(7)

Output:
queue.dequeue() returns 6
Constraints:
  • 1 <= size <= 1000

  • Each enqueue/dequeue operation is expected to be O(1).

coding Medium stack queue #4

4. Queue Implementation using Circular Buffer — Implement a queue with fixed size using a circular buffer.


Background: Optiver's trading systems require efficient data structures to handle high volumes of market data in real-time. An effective way to manage incoming data events is through a circular buffer queue, which allows efficient use of memory and quick access.
Problem statement: Implement a CircularQueue class that has a fixed size. It should allow for the operations of enqueue (adding an element to the queue), dequeue (removing an element from the front of the queue), and peek (looking at the front element without removing it). Ensure that these operations handle the wrap-around mechanism when the end of the buffer is reached. When the queue is empty, the dequeue and peek operations should return None.
Function/class signature:
  • class CircularQueue:

  • def __init__(self, size: int): # initializes the queue with a given size

  • def enqueue(self, value: Any) -> bool: # adds value to the queue, returns success

  • def dequeue(self) -> Optional[Any]: # removes and returns the front value

  • def peek(self) -> Optional[Any]: # returns the front value without removing it

  • def is_empty(self) -> bool: # checks if the queue is empty

  • def is_full(self) -> bool: # checks if the queue is full


Example 1: Input: cq = CircularQueue(3); cq.enqueue(1); cq.enqueue(2); cq.enqueue(3); cq.dequeue(); cq.peek()
Output: 2
Explanation: After dequeuing 1, the next element 2 is at front.
Example 2: Input: cq = CircularQueue(2); cq.enqueue(1); cq.enqueue(2); cq.enqueue(3)
Output: False
Explanation: The third enqueue returns False because the queue is full.
Constraints:
  • The maximum size of the queue is 1 <= size <= 1000.

  • The enqueue operation must handle the case when the queue is full gracefully.

  • Elements can be of any type, but focus on integer inputs initially for simplicity.
coding Medium queue #5

5. [Queue Implementation] — Implement a circular buffer queue

Background: Optiver relies heavily on efficient data processing and messaging systems in high-frequency trading. Implementing a circular buffer helps in managing queues of order requests efficiently, minimizing resource usage and enhancing performance.
Problem statement: Design and implement a CircularBufferQueue class that implements a circular queue with the following operations: enqueue to add an item to the queue, dequeue to remove an item, and is_empty to check if the queue is empty. The queue should have a fixed size limit to ensure efficient memory usage and prevent overflow. Use None or an alternative mechanism to represent an empty slot in the buffer.
Function/class signature:
  • class CircularBufferQueue:

  • def __init__(self, size: int):

  • def enqueue(self, item: Any) -> bool:

  • def dequeue(self) -> Any:

  • def is_empty(self) -> bool:

Example 1:
  • Input: cbq = CircularBufferQueue(3)

  • Input: cbq.enqueue(1) → Output: True

  • Input: cbq.enqueue(2) → Output: True

  • Input: cbq.dequeue() → Output: 1

  • Explanation: The circular buffer behaves as expected, the first element is dequeued after two elements are enqueued.

Example 2:
  • Input: cbq.enqueue(3) → Output: True

  • Input: cbq.enqueue(4) → Output: True

  • Input: cbq.dequeue() → Output: 2

  • Explanation: The queue allows for overwriting the oldest item when it’s full, maintaining the circular nature of the buffer.

Constraints:
  • The size of the queue will be between 1 and 1000.

  • The items in the queue can be of any type.

  • Enqueue operations should be O(1) and must handle overflow gracefully.

  • Dequeue operations should be O(1).

system design Medium queue #6

6. Design CircularBufferQueue — Implementation of a circular buffer queue


Background: In trading systems, efficient management of orders and trades is crucial for optimizing performance. A circular buffer queue can help manage orders in a first-in-first-out (FIFO) manner while utilizing fixed memory efficiently.
Requirements:
1. Implement a circular buffer with a specified capacity.
2. Provide methods to enqueue and dequeue items from the queue.
3. Ensure that the queue supports checking if it is empty or full.
4. Methods must handle concurrent access safely.
5. Provide a method to clear the queue.
Class API:
  • 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.


Example 1:
Input: 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:
Input: 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)

  • Number of enqueue and dequeue operations should not exceed 10000.

  • Proper handling of concurrent accesses should be provided.
system design Medium caching #7

7. Design CircularBuffer — Implementation of a circular buffer for efficient queue management

Background: At Optiver, software systems must efficiently handle real-time data processing and manage state changes. A circular buffer can provide efficient storage for incoming data streams, reducing overhead needed for dynamic resizing.
Requirements:
1. The buffer must be able to store a fixed maximum number of elements.
2. It should provide methods to add an element to the buffer and retrieve the oldest element.
3. Implement methods to check if the buffer is empty or full.
4. Ensure thread safety when accessing the buffer.
Class API:
  • 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.

Example 1:
Input: cb = CircularBuffer(3); cb.enqueue(1); cb.enqueue(2); cb.enqueue(3) → Output: None, Explanation: The buffer contains [1, 2, 3].
Example 2:
Input: cb.dequeue() → Output: 1, Explanation: Removes 1, buffer now contains [2, 3].
Constraints:
  • Maximum capacity of the buffer: 1 <= capacity <= 10^6.

  • Buffer operations must handle concurrent access safely.

Related Optiver Software Engineer interview prep

Start practicing Optiver questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free