As reported: DoorDash E4 phone screen (Toronto, 2025), the first of two LeetCode questions; solved optimally.
This is LeetCode 875 — Koko Eating Bananas.
There are n piles of bananas; pile i has piles[i] bananas. Koko chooses an eating speed of k bananas per hour. Each hour she picks one pile and eats k bananas from it; if the pile has fewer than k, she eats all of it and does nothing else that hour. Return the minimum integer k such that she eats all the bananas within h hours.
Example 1
piles = [3,6,7,11], h = 8
Output: 4
Example 2
piles = [30,11,23,4,20], h = 5
Output: 30
Example 3
piles = [30,11,23,4,20], h = 6
Output: 23
Constraints: 1 ≤ piles.length ≤ 10^4; piles.length ≤ h ≤ 10^9; 1 ≤ piles[i] ≤ 10^9.
Code runner format: one JSON value per line: piles, then h. Implement minEatingSpeed(piles, h); the harness prints the answer.