Two City Scheduling LeetCode challenge June Day 3
PYTHON CODE:
class Solution:
def twoCitySchedCost(self, costs: List[List[int]]) -> int:
summ = 0
costs = sorted(costs,key = lambda a:a[0]-a[1])
for i in range(len(costs)):
if i < len(costs)//2:
summ+=costs[i][0]
else:
summ+=costs[i][1]
return summ
0 Comments