Two City Scheduling with an Odd Candidate Count
Problem statement
Each row costs[i] = [newYorkCost, sanFranciscoCost] gives the travel cost for candidate i to attend an onsite interview in one of two cities.
Send exactly ceil(n / 2) candidates to New York and every remaining candidate to San Francisco. Return the minimum possible total travel cost.
Function
minimumTravelCost(costs: int[][]) → longExamples
Example 1
costs = [[10,20],[30,200],[400,50],[30,20]]return = 110Send the first two candidates to New York and the other two to San Francisco for 10 + 30 + 50 + 20 = 110.
Example 2
costs = [[10,100],[20,30],[30,20]]return = 50Because n = 3, exactly two candidates go to New York. Sending the first two there and the third to San Francisco costs 10 + 20 + 20 = 50.
Example 3
costs = [[7,3]]return = 7The New York quota is one, so the only candidate must go to New York even though San Francisco is cheaper.
Constraints
1 <= costs.length <= 100000.costs[i].length = 2.1 <= costs[i][j] <= 100000.