Skip to content

Commit ded34de

Browse files
authored
Create 875-Koko-Eating-Bananas.py
1 parent 936b0d4 commit ded34de

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

875-Koko-Eating-Bananas.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution:
2+
def minEatingSpeed(self, piles: List[int], H: int) -> int:
3+
l, r = 1, max(piles)
4+
k = 0
5+
6+
while l <= r:
7+
m = (l + r) // 2
8+
9+
totalTime = 0
10+
for p in piles:
11+
totalTime += ((p-1)//m) + 1
12+
if totalTime <= H:
13+
k = m
14+
r = m - 1
15+
else:
16+
l = m + 1
17+
return k

0 commit comments

Comments
 (0)