Bloomberg | Onsite Interview.

I had an interview with Bloomberg a few months back where i was asked the following question.

You are hosting a meeting in 2 locations. All Employess need to attend the meeting in either one of the locations. The Costs of Transporting each employee is Given.
A B
Empoloyee 1: 1500.
Employee 2: 800
...

Each Location has a Maximum limit of people it can accomodate. How would you minimize the cost.

I came up with a Greedy Solution. Where you order the employees the Absolute difference in cost(Higher First). and then assign each employee to location which is cheaper, till you can. Once one of the location is full you go ahead and assign all employees to the other location.

I am sure this is not 100% accurate. Is there any similar problem in leetcode/anywhere else. Is this a NP-Hard Problem?

Even Though I was not asked about it, A good followup question could be "How would you go about this problem if there were more than one locations?"

Comments (5)