Binary search on the answer — search the speed k, not the array. Eating speed has a clean monotonic property: if speed k finishes within h hours, any faster speed does too. That lets us binary search ...