computeSum
that takes nums
and a divisor
, and returns the sum of the division results, each rounded up to the nearest integer.left
to 1 and right
to the maximum element in nums
.left
is less than or equal to right
:
a. Calculate mid
as the average of left
and right
.
b. Use computeSum
to calculate the sum of divisions with mid
as the divisor.
c. If the sum is greater than threshold
, set left
to mid + 1
.
d. If the sum is less than or equal to threshold
, set right
to mid - 1
.left
as the smallest divisor after exiting the loop.