Trains the technique from
LeetCode 1283Find the Smallest Divisor Given a ThresholdThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A print shop binds jobs on a comb machine. pages[i] is the page count of job i, and every job is bound on its own.
A comb of size d grips at most d pages per pass, so job i occupies ceil(pages[i] / d) passes: the machine keeps taking full bites of d pages and a final short bite still uses up a whole pass.
Combs are stocked in every whole size from 1 upward, and the shop is prepared to run at most budget passes in total across all the jobs. Return the smallest comb size that keeps the total number of passes at or below budget.
budget is never smaller than the number of jobs, so some comb size always works.
Example 1
A comb of 4 takes job 0 in two passes, of 4 pages then 1, and job 1 in two passes, of 4 pages then 3. That is 4 passes altogether, which the budget allows.
Example 2
A comb of 4 grips job 0 in a single pass, job 1 in two and job 2 in three, for exactly 6 passes.
Example 3
A comb of 17 binds the one 17-page job in a single pass, which fits a budget of 1 pass.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def smallest_binder_comb(pages: list[int], budget: int) -> int:public int smallestBinderComb(int[] pages, int budget)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.