409. Find Minimum Time to Finish All Jobs
You are given an integer array jobs, where jobs[i] represents the time required to complete the i-th job.
You have k workers available to complete these jobs. Every job must be assigned to exactly one worker. A worker's total working time is the sum of the durations of all jobs assigned to them. Your objective is to distribute the jobs optimally such that the maximum working time among all workers is minimized.
Return the minimum possible maximum working time for any valid assignment.
Example 1:
Input: jobs = [4, 5, 4], k = 3
Output:5
Explanation:
Since there are 3 jobs and 3 workers, we can assign exactly one job to each worker. The working times will be 4, 5, and 4. The maximum working time is 5.
Example 2:
Input: jobs = [2, 3, 5, 8, 9], k = 2
Output: 14
Explanation:
An optimal assignment is as follows:
Worker 1 gets jobs: 5, 9 (Total time = 14)
Worker 2 gets jobs: 2, 3, 8 (Total time = 13) The maximum working time is 14.
Now Your Turn!
Pick the correct output for the given inputInput: jobs = [10, 15, 20], k = 2
(Determine the minimum possible maximum working time of any assignment)
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= k <= jobs.length <= 12
- 1 <= jobs[i] <= 107