Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Koko Eating Bananas

Medium Binary Search

There are n piles of bananas. Koko eats at a speed of k bananas per hour; in one hour she picks one pile and eats up to k bananas from it (if the pile has fewer, she finishes it and waits). She must finish all piles within h hours. Print the minimum integer k that works.

Constraints

1 <= n <= h <= 10^9 1 <= pile <= 10^9

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.