FAANG · LeetCode #875
Koko Eating Bananas — three-stage drill
1The ProblemMedium
Koko Eating Bananas
Smallest eating speed to finish all banana piles within h hours.
Examples
piles=[3,6,7,11], h=8→ 4piles=[30,11,23,4,20], h=5→ 30
constraintAnswer (speed) lies in [1, max pile]; feasibility is monotonic.
2The PatternTIME O(log n) · SPACE O(1)
Binary Search
Halve the search space each step — check the middle, keep the half that can hold the answer.
Problems using this pattern
3The SolutionRESULT → 4
Step through it
search the eating speed in [1, 11]. h = 8 hours
Step 1 / 6
Arrow keys to navigate · escape to reset