Assign jobs to k workers to minimize the maximum working time

Quick Overview

Assign up to 12 jobs with given durations to k workers so the largest total working time of any worker is as small as possible, and return that value. It tests search over subsets, bitmask dynamic programming and reasoning about why simple greedy assignment is not enough.

Assign jobs to k workers to minimize the maximum working time

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Other

You are given an integer array `jobs`, where `jobs[i]` is the time it takes to complete job `i`, and an integer `k`, the number of workers. Each job must be assigned to exactly one worker. The working time of a worker is the sum of the times of all jobs assigned to that worker. Find an assignment that makes the maximum working time over all workers as small as possible, and return that minimum possible maximum working time. ### Function Signature ```python def minimum_time_required(jobs: list[int], k: int) -> int: ``` ### Rules - A job cannot be split between workers. - A worker may be given no jobs. - Return only the minimum possible maximum working time, not the assignment itself. ### Constraints - `1 <= k <= len(jobs) <= 12` - `1 <= jobs[i] <= 10^7` ### Examples ```text Input: jobs = [3, 2, 3], k = 3 Output: 3 ``` Each worker takes one job, so the largest working time is 3. No assignment can do better, because some worker has to run a job that takes 3. ```text Input: jobs = [1, 2, 4, 7, 8], k = 2 Output: 11 ``` One worker takes jobs 1, 2 and 8 (total 11) and the other takes 4 and 7 (total 11). The jobs add up to 22, so with two workers at least one of them carries 11 or more. ```text Input: jobs = [3, 3, 2, 2, 2], k = 2 Output: 6 ``` The jobs add up to 12, so 6 is a lower bound, and the split {3, 3} and {2, 2, 2} reaches it. A split such as {3, 2, 2} and {3, 2} gives 7.

Overview: Assign up to 12 jobs with given durations to k workers so the largest total working time of any worker is as small as possible, and return that value. It tests search over subsets, bitmask dynamic programming and reasoning about why simple greedy assignment is not enough.

Nov 25, 2026
hardSoftware EngineerOtherCoding & Algorithms
0
0

You are given an integer array jobs, where jobs[i] is the time it takes to complete job i, and an integer k, the number of workers. Each job must be assigned to exactly one worker. The working time of a worker is the sum of the times of all jobs assigned to that worker.

Find an assignment that makes the maximum working time over all workers as small as possible, and return that minimum possible maximum working time.

Function Signature

def minimum_time_required(jobs: list[int], k: int) -> int:

Rules

  • A job cannot be split between workers.
  • A worker may be given no jobs.
  • Return only the minimum possible maximum working time, not the assignment itself.

Constraints

  • 1 <= k <= len(jobs) <= 12
  • 1 <= jobs[i] <= 10^7

Examples

Input: jobs = [3, 2, 3], k = 3
Output: 3

Each worker takes one job, so the largest working time is 3. No assignment can do better, because some worker has to run a job that takes 3.

Input: jobs = [1, 2, 4, 7, 8], k = 2
Output: 11

One worker takes jobs 1, 2 and 8 (total 11) and the other takes 4 and 7 (total 11). The jobs add up to 22, so with two workers at least one of them carries 11 or more.

Input: jobs = [3, 3, 2, 2, 2], k = 2
Output: 6

The jobs add up to 12, so 6 is a lower bound, and the split {3, 3} and {2, 2, 2} reaches it. A split such as {3, 2, 2} and {3, 2} gives 7.