class Solution(object):
def smallestDivisor(self, nums, threshold):
"""
:type nums: List[int]
:type threshold: int
:rtype: int
"""
start=1
end=max(nums)
s=start
e=end
def valid(mid):
sum=0
for i in nums:
sum+=(i-1)/mid+1
if sum>threshold:
return False
return True
while s<=e:
mid=s+(e-s)/2
if valid(mid):
e=mid-1
else:
s=mid+1
return s
LEETCODE1283. 使结果不超过阈值的最小除数
最新推荐文章于 2025-06-11 18:07:26 发布