← Questions

Minimum processing rate to finish before a deadline

0
AmazonCodingLast asked May 2026

A coding interview question asked in Amazon's coding round, last asked May 2026. It tests binary-search and arrays.

You have a list of jobs, each a number of work units, and a deadline of h hours. A worker runs at a fixed rate of r units per hour. Each hour it works on one job only; if the job finishes partway through the hour, the rest of that hour is wasted. Find the smallest integer rate that finishes every job within h hours.

Interface

Unless you agree on a different interface with the interviewer, assume:

  • min_rate(jobs: list[int], h: int) -> int — a job of size s takes ceil(s / r) hours.

Example

min_rate([3, 6, 7, 11], 8)        ->  4     # 1 + 2 + 2 + 3 = 8 hours; at 3 it takes 10
min_rate([30, 11, 23, 4, 20], 5)  ->  30    # one hour per job
min_rate([30, 11, 23, 4, 20], 6)  ->  23

Constraints

  • 1 <= len(jobs) <= h <= 10^9; 1 <= jobs[i] <= 10^9; up to 10^5 jobs.

Clarifying questions

  • Can unused capacity in an hour carry over to the next job? (No.)
  • Is h always at least the number of jobs?
  • Must the rate be an integer?

What a strong answer covers

  • Hours needed falls as the rate rises, so binary search the rate between 1 and max(jobs).
  • Integer ceiling division ((s + r - 1) // r) and 64-bit sums of hours.
  • O(n log(max job)) time, O(1) space.
  • Tests: h equal to the number of jobs, one job, very large h.

Follow-ups

  • Several workers run in parallel, each on its own jobs.
  • Jobs must run in order and the rate can change once.
  • Return the schedule, not just the rate.

Where it's asked

  • Amazon · Coding · Last asked May 202655 min · Usually two rounds; one is often an object-oriented design built in steps · No AI

What it tests

binary-search · arrays

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding