Code Room
CodingMediumcod-g557
Subject Binary searchLevel Mid–Senior~22 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

There are n piles of bananas; piles[i] is the count in pile i. A guard returns in h hours. Each hour you choose one pile and eat up to speed bananas from it (if a pile has fewer than speed left, you finish it and move on, but you only eat from one pile per hour). Return the minimum integer speed so that you can eat all bananas within h hours. len(piles) <= h <= 1e9 and pile sizes up to 1e9.

Implement
min_eating_speed(piles: list[int], h: int) → int
Examples
in[[3,6,7,11],8]out4
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.