Let's suppose Bloomberg is sponsoring a coding competition at it's New york and San francisco offices. We will have to fly the participants to either one of this two offices. Each office can only accomodate only half of the participants. The goal is to assign each participant to an office in a way that the total travel cost for the company is minimized. Each participant will be presented as a pair of costs:<costToFlyToNY, costToFlyToSF>.
Determine the minimum cost given a list of participants.
https://leetcode.com/problems/two-city-scheduling/
Sample Inputs - Expected outpts
1) Participants list as <costToFlyToNY, costToFlyToSF>:
<500, 600>,
<600, 400>,
<200, 900>,
<700, 300>
Output: 1400
With only 4 participants, 2 must fly to SF and 2 must fly to NY.2) Participants list as <costToFlyToNY, costToFlyToSF>:
<0, 10>,
<9, 20>,
Output: 19
With only 2 participants, 1 must fly to SF and 1 must fly to NY.