Find Minimum Time to Finish All Jobs

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.

Example 1
Inputjobs = [3,2,3], k = 3
Output3
By assigning each person one job, the maximum time is 3.
Example 2
Inputjobs = [1,2,4,7,8], k = 2
Output11
Assigning jobs [1, 2, 8] to one worker and [4, 7] to the other gives both workers a working time of 11, so the maximum working time is 11.

Constraints

  • 1 <= k <= jobs.length <= 12
  • 1 <= jobs[i] <= 10^7

Asked at 5 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate