← All problems
The slowest speed that finishes
Problem
There are n piles of bananas, piles[i] bananas in each. You eat at a speed of k bananas per hour, choosing one pile per hour (if it has fewer than k, you finish it and wait). Return the minimum integer k that lets you eat all the bananas within h hours (h ≥ n).
Examples
Input: piles = [3, 6, 7, 11], h = 8
Output: 4
Input: piles = [30, 11, 23, 4, 20], h = 6
Output: 23
Hints
Try it first. Every hint reveals a bit more.