Problem 55 of 75

Koko Eating Bananas

MediumNot solved yetInterview me on this
Before you code · which pattern fits?

The problem

Koko has piles of bananas and h hours. Each hour she eats up to k bananas from one pile. Return the minimum integer k so she can eat all the bananas within h hours.

(piles=[3,6,7,11], h=8) → 4 (piles=[30,11,23,4,20], h=5) → 30

Your solution runs against 3 unit tests, including edge and large-value cases.

Loading...

Test console · 3 unit tests

Submit your code to run it against all 3 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.

Hint

Reference solution

Video explanation

Koko Eating Bananas, explainedNeetCode