Geeksforgeeks

Error

×

Leaderboard

Showing:

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 | |

Handle | Score |

@cfwong8 | 1160 |

@gurshehzadsingh | 1052 |

@nithinreddy3210 | 801 |

@mohanreddy8847 | 702 |

@balwanyadav34 | 622 |

@satyamchhatrala | 616 |

@pritsahkar2000 | 614 |

@AkashLahoty | 606 |

@amangiri168 | 596 |

@iamchaitanyahegde | 589 |

@iib2019024 | 587 |

Complete Leaderboard |

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:**

Input:N =2Arr[] ={3, 5, 10, 1}Output:4Explanation: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:**

Input:N =3Arr[] ={2, 1, 2, 9, 8, 1, 1, 1, 1}Output:3Explanation: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 N^{2} as input and returns the time taken for the best possible assignment.

**Expected Time Complexity:** O(N^{2})

**Expected Auxiliary Space:** O(N^{2})

**Constraints:**

1 <= N <= 30

1 <= Arr[i] <= 100

Login 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?

YesLoading...

Assignment Problem

...