Corporate Flight Bookings

Problem Id: 1109 Difficulty: Medium


Intuition

Solution


class Solution:
    def corpFlightBookings(self, bookings: List[List[int]], n: int) -> List[int]:
        change = [0] * (n + 2)
        for start, end, seats in bookings:
            change[start] += seats
            change[end + 1] -= seats
        ans = []
        flight = 1
        tmp = 0

        while flight <= n:
            tmp += change[flight]
            ans.append(tmp)
            flight += 1
        return ans