Problem · Array
Koko Eating Bananas
Problem statement
You are given an array piles of positive banana counts and an integer h. Koko chooses one nonempty pile each hour and eats up to k bananas from that pile, where k is a positive integer speed. If the pile contains fewer than k bananas, she empties it and does not start another pile during that hour.
The problem statement continues
ProExamples
Example 1
piles = [4,9,13]h = 8return = 4At speed 4, the piles take 1 + 3 + 4 = 8 hours. Speed 3 needs 2 + 3 + 5 = 10 hours, so 4 is minimal.
FastPrep Pro
Reported in 1 Amazon interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$9/month
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week