My code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Solution:
    def minEatingSpeed(self, piles: List[int], h: int) -> int:
        left = 1
        right = max(piles)

        while left < right:
            k = (left + right) // 2
            cur_h = 0
            for n in piles:
                cur_h += n // k
                if n % k != 0:
                    cur_h += 1
                    
            if cur_h <= h:
                right = k
            elif cur_h > h:
                left = k + 1
        return right
            
        
1
2
Runtime : 353ms (beats 79.03%)   
Memory : 17.84MB (beats 76.18%)