Koko Eating Bananas

Medium

Topics
ArrayBinary Search

Koko has piles of bananas (nums) and h hours (passed as target) before the guards return. Each hour she eats up to k bananas from one pile. Return the minimum integer speed k so she finishes all piles within h hours.

Example 1

Input:  piles = [3,6,7,11], h = 8
Output: 4

Example 2

Input:  piles = [30,11,23,4,20], h = 5
Output: 30

Constraints

  • 1 <= piles.length <= 10^4
  • piles.length <= h <= 10^9
  • 1 <= piles[i] <= 10^9
Run ⌘' · Submit ⌘⏎