https://leetcode.com/problems/cutting-ribbons/
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 4 months ago