Greedy Algorithms - Two City Scheduling
Given the following code and input, what is the final returned total cost?
def twoCitySchedCost(costs):
costs.sort(key=lambda x: x[0] - x[1])
n = len(costs) // 2
total = 0
for i, cost in enumerate(costs):
if i < n:
total += cost[0]
else:
total += cost[1]
return total
costs = [[10,20],[30,200],[400,50],[30,20]]
print(twoCitySchedCost(costs))
