Practice/Snowflake/Leetcode 1723. Find Minimum Time to Finish All Jobs
CodingMust
You are given an array of positive integers tasks where tasks[i] represents the time required to complete the i-th task. You need to distribute all tasks among exactly k workers. Each task must be assigned to exactly one worker, and each worker can handle any number of tasks.
Your goal is to minimize the maximum total workload assigned to any single worker. Return this minimum possible maximum workload.
k workersExample 1:
Input: tasks = [3, 2, 3], k = 2 Output: 5 Explanation: Assign tasks [3, 2] to worker 1 (total = 5) and task [3] to worker 2 (total = 3). The maximum workload is 5, which is optimal.
Example 2:
Input: tasks = [1, 2, 4, 7, 8], k = 5 Output: 8 Explanation: With 5 workers and 5 tasks, assign one task per worker. The maximum workload is 8.
Example 3:
Input: tasks = [5, 5, 4, 4, 4], k = 3 Output: 9 Explanation: One optimal distribution assigns [5, 4] to worker 1, [5, 4] to worker 2, and [4] to worker 3. The maximum workload is 9.