← 返回 doordash 的题目列表Koko Eating Bananas
类型:online_judge
doordash
Problem Description
Koko lives in a banana farm. Each hour, she can choose any banana pile to eat from, with a limit on how many bananas she can eat per hour. Given a list of piles representing the number of bananas in each pile, determine the minimum eating speed that allows Koko to eat all the bananas within h hours.
Input
piles: an array of positive integers representing banana piles, where 1 to $10^4$ elements are possible.
h: an integer indicating how many hours Koko has, with 1 ≤ h ≤ $10^9$.
Output
Minimum integer representing Koko's eating speed.
Example
Input: piles = [3,6,7,11], h = 8 Output: 4
Input: piles = [30,11,23,4,20], h = 5 Output: 30
Input: piles = [30,11,23,4,20], h = 6 Output: 23
Example
Input
3 6 7 11
8