标签:val book ict span nbsp tco end base solution
1 class Solution: 2 def corpFlightBookings(self, bookings: ‘List[List[int]]‘, n: int) -> ‘List[int]‘: 3 dic = dict() 4 for begin,end,val in bookings: 5 if begin in dic: 6 dic[begin] += val 7 else: 8 dic[begin] = val 9 if (end+1) in dic: 10 dic[end+1] -= val 11 else: 12 dic[end+1] = -val 13 res = [0] * n 14 #print(dic) 15 baseval = 0 16 for i in range(n): 17 if (i+1) in dic: 18 baseval += dic[(i+1)] 19 res[i] = baseval 20 return res
标签:val book ict span nbsp tco end base solution
原文地址:https://www.cnblogs.com/asenyang/p/11145985.html