algorythms
Modified Binary Search
LC #875Medium

Koko Eating Bananas

Modified Binary Search
AmazonGoogleMeta

Problem

Find the minimum eating speed k such that Koko can eat all bananas in h hours.

arraybinary-search

Constraints

  • 1 ≤ piles.length ≤ h ≤ 10⁹
  • 1 ≤ piles[i] ≤ 10⁹

Example

Inputpiles = [3, 6, 7, 11], h = 8
Output4
Why

At speed 4: [1,2,2,3] hours = 8 total. Speed 3 needs 9 hours (too slow)

Hints — reveal one at a time