Handle Score
@Ibrahim Nash 6424
@blackshadows 6380
@mb1973 5704
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3673
@mantu_singh 3532
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
Assignment Problem
Hard Accuracy: 53.46% Submissions: 129 Points: 8

You are the head of a firm and you have to assign jobs to people. You have N persons working under you and you have N jobs that are to be done by these persons. Each person has to do exactly one job and each job has to be done by exactly one person. Each person has his own capability (in terms of time taken) to do any particular job. Your task is to assign the jobs to the persons in such a way that the total time taken is minimum. A job can be assigned to only one person and a person can do only one job.


Example 1:

N = 2
Arr[] = {3, 5, 10, 1}
The first person takes times 3 and 5
for jobs 1 and 2 respectively. The second
person takes times 10 and 1 for jobs 1 and
2 respectively. We can see that the optimal
assignment will be to give job 1 to person 1
and job 2 to person 2 for a total for 3+1 = 4.

Example 2:

N = 3
Arr[] = {2, 1, 2, 9, 8, 1, 1, 1, 1}
The optimal arrangement would be to assign 
job 1 to person 2,job 2 to person 3 and job 
3 to person 1.


Your Task:
You don't need to read input or print anything. Your task is to complete the function assignmentProblem() which takes an Integer N and an array Arr[] of size N2 as input and returns the time taken for the best possible assignment.


Expected Time Complexity: O(N2)
Expected Auxiliary Space: O(N2)


1 <= N <= 30
1 <= Arr[i] <= 100

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Assignment Problem

Output Window