Skip to content

Commit ca1c004

Browse files
committed
make it clean and readable
1 parent cc6a923 commit ca1c004

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

1283.find-the-smallest-divisor-given-a-threshold.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ def smallestDivisor(self, nums: List[int], threshold: int) -> int:
1111
l, r = 1, max(nums)
1212
while l < r:
1313
m = (l + r) // 2
14-
if sum((i + m - 1) // m for i in nums) > threshold:
15-
l = m + 1
16-
else:
14+
sum = 0
15+
for num in nums:
16+
sum += math.ceil(num/m)
17+
if sum <= threshold:
1718
r = m
19+
else:
20+
l = m + 1
1821
return l
1922

2023

0 commit comments

Comments
 (0)