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

Question

A monkey eats bananas from n piles; pile i has piles[i] bananas. It picks an eating speed k bananas/hour. Each hour it eats from a single pile; if that pile has fewer than k bananas it eats them all and stops for that hour. Given it has h hours before the guards return, return the minimum integer speed k so it finishes all bananas in time. Constraints: 1 <= n <= 10^4, n <= h <= 10^9, 1 <= piles[i] <= 10^9.

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.