Code RoomMinimum eating speed
MediumPrep Room Coding #1124

Minimum eating speed

CodingAlgorithms & data structuresMid–Senior~22 min

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.

0:00 of about 22 min
InputExpectedGot
[[3,6,7,11],8]4not run yetsample