Skip to content

Commit 04386fd

Browse files
committed
875
1 parent 742c6ab commit 04386fd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

BS/875.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## Koko Eating Bananas
2+
3+
#### Description
4+
5+
[link](https://leetcode.com/problems/koko-eating-bananas/)
6+
7+
---
8+
9+
#### Solution
10+
11+
- See Code
12+
13+
要注意边界,l要至少从1起步,其他就是标准的Binary Search问题
14+
15+
---
16+
17+
#### Code
18+
19+
O(klog(n))
20+
21+
```python
22+
class Solution:
23+
def minEatingSpeed(self, piles: List[int], H: int) -> int:
24+
l, r = 1, max(piles)
25+
while l < r:
26+
mid = l + (r - l) // 2
27+
if sum([ceil(x / mid) for x in piles]) > H:
28+
l = mid + 1
29+
else:
30+
r = mid
31+
return l
32+
```

0 commit comments

Comments
 (0)