FastPrepLoad Balancing

Load Balancing

MathWorks logoMathWorks● MediumINTERNOA
Learn

Problem statement

Implement a prototype of a resource allocation system in a distributed parallel computing infrastructure.

There are n resources and m tasks to schedule on them where the p^th task has a processing time of burstTime[i]. The total load time of a resource is the sum of the total burst times of the jobs assigned to the resources. However, a particular resource can be allocated jobs in a contiguous segment only i.e. from some index x to some index y or [x, x + 1, x + 2, ..., y].

Find the minimum possible value of the maximum total load time of the servers if resources are allocated optimally.

Function

loadBalancing(n: int, burstTime: int[]) → int

Complete the function loadBalancing in the editor.

loadBalancing has the following parameters:

  1. 1. int n: the number of resources
  2. 2. int[] burstTime: an array of integers representing the processing times of tasks

Returns int: the minimum possible value of the maximum total load time of the servers

Examples

Example 1

n = 3burstTime = [7, 2, 3, 4, 5]return = 9

It is optimal to allocate the first job to the first resource, the last job to the second resource, and the remaining three jobs to the third resource. Total load times are 7, 5, and 2 + 3 + 4 = 9 respectively.

Constraints

  • Unknown for now

More MathWorks problems

See MathWorks hiring insights
public int loadBalancing(int n, int[] burstTime) {
    // write your code here
}
n3
burstTime[7, 2, 3, 4, 5]
expected9
Checking account…