medium

Koko Eating Bananas

There are n piles of bananas and h hours. Each hour Koko picks one pile and eats up to k bananas from it (if the pile is smaller she finishes it and waits). Find the minimum integer speed k that lets her finish every pile within h hours.

Constraints
  • 1 ≤ n ≤ 10^4
  • n ≤ h ≤ 10^9
  • 1 ≤ piles[i] ≤ 10^9
Examples
in: piles = [3,6,7,11], h = 8
out: 4
in: piles = [30,11,23,4,20], h = 5
out: 30

Code it yourself

Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?

Choose an approach to check your pattern recognition, or reveal the discussion when you need help.