← Optiver Interview Insights

Optiver·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Optiver software engineer interview with a coding round that came down to a classic binary search problem. Nothing too wild but the constraint setup requires you to actually think through the search space carefully.

Questions Asked (1)

Q1

Given n piles of bananas and h hours before the guards return, find the minimum eating speed k (bananas per hour) such that all piles are finished in time. Each hour you pick one pile and eat up to k bananas from it.

Algorithms & Data Structures
Author's notes

Binary search on the answer, not on the input array.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that the minimum eating speed can be found by binary searching over the answer space from 1 to max(piles). For each candidate speed, compute the total hours needed using the ceiling division formula and check if it's ≤ h. The first feasible speed is the minimum.

Pro tip: Mention that the time complexity is O(n log m) where m is the maximum pile size, and that this is optimal because the feasibility check is monotonic. Also, explicitly state the ceiling division formula to show attention to detail.

1. Define the search space

The minimum speed is at least 1 and at most the size of the largest pile, since eating faster than the largest pile doesn't help. So set low = 1, high = max(piles).

2. Define feasibility check

For a given speed k, the hours needed for a pile of size p is ceil(p / k). Sum these hours over all piles and check if the total is ≤ h.

3. Binary search for minimum k

While low < high, compute mid = (low + high) // 2. If feasible(mid), set high = mid; else set low = mid + 1. Return low as the minimum speed.

4. Analyze complexity

The binary search takes O(log m) iterations, and each feasibility check takes O(n) time, giving O(n log m) total time and O(1) extra space.

Key Points to Mention

  • Binary search on the answer (speed) rather than on the piles.
  • Ceiling division formula: (p + k - 1) // k to compute hours per pile.
  • Monotonicity: if speed k is feasible, any speed > k is also feasible.
  • Time complexity: O(n log m) where m = max(piles).
  • Edge cases: h < n (impossible), h = n (must eat max pile per hour), large h (speed 1).
  • Alternative: linear search would be O(n * m) and too slow for large inputs.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.