Find the Smallest Divisor Given a Threshold
Medium
Topics
Given an array nums and an integer target (the threshold), find the smallest positive divisor d such that the sum of ceil(nums[i] / d) over all elements is less than or equal to target. It is guaranteed that a valid divisor exists.
Example 1
Input: nums = [1,2,5,9], target = 6 Output: 5
Example 2
Input: nums = [44,22,33,11,1], target = 5 Output: 44
Constraints
- 1 <= nums.length <= 5*10^4
- 1 <= nums[i] <= 10^6
- nums.length <= target <= 10^6
Run ⌘' · Submit ⌘⏎