Find the Smallest Divisor Given a Threshold
MediumBinary Search
Decode it first. Clues, constraints, pattern and plan before any code.Given a list of positive integers nums and an integer threshold, choose a positive integer divisor d. Divide every number by d, rounding each result up, and add the results. Return the smallest divisor whose total is <= threshold.
nums = [1, 2, 5, 9], threshold = 6 → 5 (1 + 1 + 1 + 2 = 5)
nums = [44, 22, 33, 11, 1], threshold = 5 → 44
nums = [2, 3, 5, 7, 11], threshold = 11 → 3Constraints
1 <= nums.length <= 5 * 10^41 <= nums[i] <= 10^6nums.length <= threshold <= 10^6