307. Koko Eating Bananas
MediumBinary Search
Koko loves to eat bananas. There are n piles of bananas, where the i-th pile has piles[i] bananas. The guards will return in h hours. Koko can decide her bananas-per-hour eating speed k. Each hour, she chooses a pile and eats k bananas from it. If the pile has fewer than k bananas, she eats all of them and waits for the next hour. Return the minimum integer k such that she can eat all the bananas within h hours.
Examples
Input: [3,6,7,11,8,5,12] 10
Output: 7
Explanation: Public test case for Koko Eating Bananas
Constraints
- 1 <= piles.length <= 10^4
- 1 <= piles[i] <= 10^9
- 1 <= h <= 10^9
Loading...
Run checks all cases above. Submit evaluates all test cases.