Reading about question types isn't enough — truly mastering the Optiver OA takes fully worked sample questions. This article picks three representative samples and walks them end to end, from prompt to code to variants, so you build transferable solution patterns.
Optiver OA Overview
| Dimension | Detail |
|---|---|
| Platform | HackerRank / CodeSignal / proprietary |
| Duration | 60–75 minutes |
| Questions | 2–4 |
| Difficulty | LeetCode Medium+, simulation and math heavy |
| Focus | Sliding window, greedy, expected value |
Sample 1: Sliding Window Maximum (Price Stream)
Prompt: Given a per-second price array prices and window size k, output the highest price within each window of length k (simulating live monitoring).
Idea: Brute force is O(nk). A monotonic decreasing deque brings it to O(n): the front is always the current window max.
from collections import deque
def max_sliding_window(prices, k):
dq = deque() # store indices; corresponding prices are decreasing
result = []
for i, p in enumerate(prices):
# drop indices outside the window
if dq and dq[0] <= i - k:
dq.popleft()
# drop smaller tails (they can never be the max again)
while dq and prices[dq[-1]] < p:
dq.pop()
dq.append(i)
if i >= k - 1:
result.append(prices[dq[0]])
return result
Time complexity: O(n) Variant: window minimum price, or output the max–min spread.
Sample 2: Weighted Median (Volume-Weighted Price)
Prompt: Given several (price, volume) pairs, find the volume-weighted median — the price at which cumulative volume first reaches half the total.
Idea: Sort by price, accumulate volume, find the price that crosses the halfway mark.
def weighted_median(pairs):
# pairs: [(price, volume), ...]
pairs.sort()
total = sum(v for _, v in pairs)
cum = 0
for price, vol in pairs:
cum += vol
if cum * 2 >= total: # cumulative volume reaches half
return price
return pairs[-1][0]
Time complexity: O(n log n) Pitfall: mind the "exactly half" boundary and the definition for even totals.
Sample 3: Gambling Expectation (Stopping Time)
Prompt: Each round, flip a fair coin; heads gives +1 point, tails stops. Find the expected score.
Idea: A classic stopping-time expectation. Let the expectation be E; each round has 1/2 chance to continue with +1, 1/2 to stop: E = 1/2 × (1 + E), giving E = 1.
def expected_score(p_continue=0.5, reward=1):
# E = p*(reward + E) => E = p*reward / (1 - p)
return p_continue * reward / (1 - p_continue)
Key: Recognizing the "self-referential expectation equation" is the key to this family — most stopping-time problems solve instantly this way.
Common Pitfalls Checklist
❌ Sliding window forgetting to drop expired indices ❌ Weighted median mistaking "count median" for "weight median" ❌ Brute-forcing expectation problems — slow and imprecise ✅ See monotonicity → think deque ✅ See "until ..." → think stopping-time equation
FAQ
How close are these samples to the real test? Question types are highly consistent: sliding window, greedy, and expected value are recurring themes — master these and their variants to cover most real questions.
What language is best for these? Python saves the most time — deque, heapq, sort are built-in weapons. C++ is steadier at extreme data sizes; choose by your fluency.
Must I set up equations for expectation problems? Strongly recommended. Stopping-time and recursive-expectation problems solve in seconds with equations; brute simulation is slow and error-prone on precision.
What should I practice after the samples? Timing and variants. Optiver tests speed most — write 2–3 variants of each theme until it's muscle memory.
I know the samples but I'm still slow on the day — what then? We provide Optiver OA support: timed practice with real-difficulty samples to turn "can solve" into "can solve fast and correct."
Preparing for the Optiver OA?
Mastering the core themes and drilling variants is the only shortcut to speeding up the Optiver OA. Our mentors offer deep dives and timed mocks on sliding window, weighted statistics, and expectation problems. For a systematic plan, reach out — contact WeChat Coding0201 to get real questions and prep materials.
Contact
Email: [email protected] Telegram: @OAVOProxy