25. Koko Eating Bananas

There are piles[i] bananas in each pile. Each hour Koko picks one pile and eats up to k bananas from it (if the pile has fewer, she finishes it and waits for the hour to end). Return the minimum integer speed k that lets her finish everything within h hours.

Example 1

Input: piles = [3,6,7,11], h = 8
Output: 4
Explanation: At speed 4 she needs 1 + 2 + 2 + 3 = 8 hours.

Example 2

Input: piles = [5,9,2], h = 5
Output: 5
Hint 1

If speed k works, any faster speed also works: the answer space is monotonic.

Hint 2

Binary-search the speed between 1 and max(piles).

Binary Search on Answer