Skip to content

Latest commit

 

History

History
21 lines (19 loc) · 559 Bytes

875.md

File metadata and controls

21 lines (19 loc) · 559 Bytes

873. Length of Longest Fibonacci Subsequence

Solution 1 (time O(n*max(piles)), space O(1))

class Solution(object):
    def minEatingSpeed(self, piles, h):
        """
        :type piles: List[int]
        :type h: int
        :rtype: int
        """
        left, right = 1, max(piles)
        while left < right:
            mid = (left + right) // 2
            if sum((pile + mid - 1) // mid for pile in piles) > h:
                left = mid + 1
            else:
                right = mid
        return left