Minimum eating speed

Write codeMedium22 minAmazon and Meta style

Your task

There are n piles of bananas; piles[i] is the count in pile i. A guard returns in h hours. Each hour you choose one pile and eat up to speed bananas from it (if a pile has fewer than speed left, you finish it and move on, but you only eat from one pile per hour). Return the minimum integer speed so that you can eat all bananas within h hours. len(piles) <= h <= 1e9 and pile sizes up to 1e9.

Examples

min_eating_speed(piles: list[int], h: int) -> int
Example 1
Inputmin_eating_speed([3, 6, 7, 11], 8)
Output4