*1891. Cutting Ribbons
https://leetcode.com/problems/cutting-ribbons/
solution
class Solution:
    def maxLength(self, ribbons: List[int], k: int) -> int:
        left = 0
        right = max(ribbons)
        while left < right:
            mid = (left + right + 1) // 2
            count = sum(ribbon // mid for ribbon in ribbons)
            if count >= k:
                left = mid
            else:
                right = mid - 1
        return left时间复杂度:O() 空间复杂度:O()
Last updated