dsa · medium

Koko Eating Bananas

GreyOrangeBinary SearchGreedy

piles[i] bananas; Koko eats at speed k bananas/hour (ceil per pile). Finish in h hours. Return the **minimum** k.

Arguments

**Example:** [3,6,7,11], h=84.

Constraints

1 <= piles.length <= 1000, piles.length <= h <= 10^9 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[3,6,7,11]
8

Expected:
4

Example 2

Input:
[30,11,23,4,20]
5

Expected:
30

Open in the Dojo editor