1109. Corporate Flight Bookings - cocoder39/coco39_LC GitHub Wiki
1109. Corporate Flight Bookings
class Solution:
def corpFlightBookings(self, bookings: List[List[int]], n: int) -> List[int]:
events = collections.defaultdict(int)
for first, last, seats in bookings:
events[first] += seats
events[last+1] -= seats
res = []
total = 0
for i in range(1, n+1):
total += events[i]
res.append(total)
return res