Leetcode 1095 Solution
This article provides solution to leetcode question 1095 (two-city-scheduling)
Access this page by simply typing in "lcs 1095" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/two-city-scheduling
Solution
class Solution:
def twoCitySchedCost(self, costs: List[List[int]]) -> int:
n = len(costs) // 2
costs = sorted([(cost1 - cost2, cost1, cost2) for cost1, cost2 in costs])
return sum([cost1 for _, cost1, _ in costs[0:n]] + [cost2 for _, _, cost2 in costs[n:]])