Find the Smallest Divisor Given a Threshold
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given an integer array nums and an integer threshold, choose a positive integer divisor d. Divide every element by d, rounding each result **up** to the nearest integer, and add the results together.
Return the smallest d for which that sum is less than or equal to threshold. The input guarantees threshold >= nums.length, so an answer always exists (dividing by max(nums) makes every term 1).
Examples
Constraints
- `1 <= nums.length <= 5 * 10^4`
- `1 <= nums[i] <= 10^6`
- `nums.length <= threshold <= 10^6`
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.