Skip to content

Commit

Permalink
Create 875-Koko-Eating-Bananas.py
Browse files Browse the repository at this point in the history
  • Loading branch information
neetcode-gh authored Dec 26, 2021
1 parent 936b0d4 commit ded34de
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 875-Koko-Eating-Bananas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution:
def minEatingSpeed(self, piles: List[int], H: int) -> int:
l, r = 1, max(piles)
k = 0

while l <= r:
m = (l + r) // 2

totalTime = 0
for p in piles:
totalTime += ((p-1)//m) + 1
if totalTime <= H:
k = m
r = m - 1
else:
l = m + 1
return k

0 comments on commit ded34de

Please sign in to comment.