875. Koko Eating Bananas

Practice Koko Eating Bananas for free on NudgeCode: Medium, Binary Search pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

There are several piles of bananas; piles[i] is the size of pile i. You eat at a fixed speed of k bananas per hour. Each hour you pick one pile and eat up to k bananas from it; if the pile has fewer than k, you finish it and wait out the rest of that hour.

Return the smallest integer k that lets you finish every pile within h hours.

Example

piles = [3,6,7,11], h = 8  ->  4

Constraints