The problem. Koko has piles of bananas and h hours before the guards return. Each hour she picks one pile and eats k bananas from it; if the pile has fewer than k, she eats them all and waits out the rest of the hour. Return the smallest speed `k` that lets her finish every pile within h hours.
piles = [3, 6, 7, 11], h = 8 -> 4
piles = [30, 11, 23, 4, 20], h = 5 -> 30
piles = [30, 11, 23, 4, 20], h = 6 -> 23Members only · free account
The rest of this lesson, with 6 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson