← Eightfold AI Interview Insights

Eightfold AI·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Coding round at Eightfold AI for a software engineer position. One algorithmic problem, binary search on the answer type, the kind that looks approachable until you're mid-implementation and second-guessing your bounds.

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. Solve it using binary search.

Algorithms & Data Structures
Author's notes

Classic binary search on the answer problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize that the minimum eating speed k lies between 1 and the maximum pile size. Use binary search to efficiently find the smallest k such that the total hours required to eat all piles (sum of ceil(pile/k)) is ≤ h. For each candidate k, compute the total hours in O(n) time, resulting in O(n log m) overall, where m is the maximum pile size.

Pro tip: During the interview, explicitly state the time and space complexity and discuss edge cases like when h is less than the number of piles (impossible) or when h is very large (k=1). Also, mention that the binary search is on the answer space, not the array indices.

1. Understand the problem and constraints

Clarify that each hour you choose one pile and eat up to k bananas from it. If the pile has fewer than k bananas, you finish it and cannot eat from another pile that hour. The goal is to find the minimum integer k such that all piles are finished within h hours.

2. Define the search space

The minimum possible speed is 1 (if h is large enough) and the maximum needed speed is the size of the largest pile (since eating faster than that doesn't reduce hours further). So set low = 1, high = max(piles).

3. Implement the feasibility check

For a given k, compute the total hours required: sum over piles of ceil(pile / k). If this sum is ≤ h, then k is feasible; otherwise, it's not.

4. Binary search for the minimum feasible k

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

5. Analyze complexity and edge cases

Time complexity: O(n log m) where n is number of piles and m is max pile size. Space: O(1). Discuss edge cases: if h < n, return -1 or indicate impossible; if h is very large, answer is 1.

Key Points to Mention

  • Binary search on the answer space (speed k) rather than on the array.
  • Feasibility function: sum of ceil(pile/k) ≤ h.
  • Time complexity: O(n log m) where m = max(piles).
  • Space complexity: O(1) extra space.
  • Edge case: if h < number of piles, it's impossible to finish all piles.
  • Use integer division trick: (pile + k - 1) // k to compute ceil without floating point.

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