875. Koko Eating Bananas
Intuition
Koko wants to finish eating all the bananas within h
hours. She eats from one pile per hour, and the speed k
(bananas/hour) is the same for all hours. The faster she eats, the fewer hours she'll take.
The problem is to find the minimum possible eating speed k
such that total time ≤ h
. Since the relationship between speed and hours is monotonic (higher speed → fewer hours), we can apply binary search on k
.
Complexity
Space Complexity
Time Complexity
Code
Last updated