Koko Eating Bananas
Medium
LC #875
binary search on answerNot attempted yet
Koko has piles of bananas, piles[i] in the
i-th pile, and h hours before the guards return.
She picks an eating speed k (bananas per hour).
Each hour she chooses one pile and eats k bananas
from it; if the pile has fewer than k, she finishes
it and waits out the rest of that hour.
Return the minimum integer k that lets her eat
every banana within h hours.
Example 1
Input: piles = [3,6,7,11], h = 8
Output: 4
Explanation: 1 + 2 + 2 + 3 = 8 hours.
Example 2
Input: piles = [30,11,23,4,20], h = 5
Output: 30
Example 3
Input: piles = [30,11,23,4,20], h = 6
Output: 23
Constraints
- 1 <= piles.length <= 10^4
- piles.length <= h <= 10^9
- 1 <= piles[i] <= 10^9