Skip to content

Commit

Permalink
Time: 53 ms (63.71%), Space: 14 MB (17.48%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
r-rahul1 committed Mar 25, 2022
1 parent 25df5b0 commit 9a75cd4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 1029-two-city-scheduling/1029-two-city-scheduling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution:
def twoCitySchedCost(self, costs: List[List[int]]) -> int:
diff = []
for a,b in costs:
diff.append([b-a,a,b])

diff.sort()
res = 0
for i in range(len(diff)):
if i < len(diff)//2:
res += diff[i][2]
else:
res += diff[i][1]

return res

0 comments on commit 9a75cd4

Please sign in to comment.