Two City Scheduling
MediumGreedy
Decode it first. Clues, constraints, pattern and plan before any code.A company is flying 2n people to interviews. costs[i] = [a, b] is the price of flying person i to city A or to city B. Exactly n people must go to each city. Return the minimum total cost.
costs = [[10, 20], [30, 200], [400, 50], [30, 20]] → 110 (A, A, B, B)
costs = [[20, 10], [10, 20]] → 20Constraints
2 * n == costs.length2 <= costs.length <= 100costs.lengthis even.1 <= a, b <= 1000