Find Minimum Time to Finish All Jobs - Problem
You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the i-th job.
There are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum of the time it takes to complete all jobs assigned to them. Your goal is to devise an optimal assignment such that the maximum working time of any worker is minimized.
Return the minimum possible maximum working time of any assignment.
Input & Output
Example 1 — Basic Case
$
Input:
jobs = [3,2,3], k = 3
›
Output:
3
💡 Note:
Assign each job to a different worker: Worker 1 gets job with time 3, Worker 2 gets job with time 2, Worker 3 gets job with time 3. Maximum working time is max(3,2,3) = 3.
Example 2 — Optimal Assignment
$
Input:
jobs = [1,2,4,7,8], k = 2
›
Output:
11
💡 Note:
Assign jobs optimally: Worker 1 gets jobs [1,2,8] with total time 11, Worker 2 gets jobs [4,7] with total time 11. Both workers finish at time 11.
Example 3 — Single Worker
$
Input:
jobs = [5,3,7], k = 1
›
Output:
15
💡 Note:
Only one worker must do all jobs: 5 + 3 + 7 = 15. The minimum possible maximum working time is 15.
Constraints
- 1 ≤ k ≤ jobs.length ≤ 12
- 1 ≤ jobs[i] ≤ 107
Visualization
Tap to expand
Understanding the Visualization
1
Input
Jobs [3,2,3] and k=3 workers
2
Process
Find assignment minimizing maximum worker time
3
Output
Optimal assignment with max time = 3
Key Takeaway
🎯 Key Insight: Binary search the maximum time and verify feasibility with backtracking
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code