Find Minimum Time to Finish All Jobs II - Problem
You are given two 0-indexed integer arrays jobs and workers of equal length, where jobs[i] is the amount of time needed to complete the i-th job, and workers[j] is the amount of time the j-th worker can work each day.
Each job should be assigned to exactly one worker, such that each worker completes exactly one job.
Return the minimum number of days needed to complete all the jobs after assignment.
Input & Output
Example 1 — Basic Case
$
Input:
jobs = [3,2,3], workers = [1,1,1]
›
Output:
3
💡 Note:
Each worker can work 1 hour per day. Jobs take 3, 2, and 3 hours respectively. The workers need ceil(3/1)=3, ceil(2/1)=2, and ceil(3/1)=3 days. Maximum is 3 days.
Example 2 — Optimal Assignment
$
Input:
jobs = [1,2,4,7,8], workers = [2,4,1,4,7]
›
Output:
2
💡 Note:
Optimal assignment: job 8→worker 7 (2 days), job 7→worker 4 (2 days), job 4→worker 4 (1 day), job 2→worker 2 (1 day), job 1→worker 1 (1 day). Maximum is 2 days.
Example 3 — Equal Capacity
$
Input:
jobs = [5,5,5], workers = [5,5,5]
›
Output:
1
💡 Note:
Each worker can complete their assigned job in exactly 1 day since job time equals worker capacity.
Constraints
- 1 ≤ jobs.length == workers.length ≤ 12
- 1 ≤ jobs[i], workers[i] ≤ 1000
Visualization
Tap to expand
Understanding the Visualization
1
Input
Two arrays: jobs=[3,2,3], workers=[1,1,1]
2
Assignment
Each job assigned to exactly one worker
3
Days Calculation
Worker days = ceil(job_time/worker_capacity)
4
Output
Maximum days across all workers
Key Takeaway
🎯 Key Insight: The bottleneck determines completion time - minimize the maximum days any worker needs
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code