Corporate Flight Bookings
Medium
LC #1109
difference arrayprefix sumNot attempted yet
There are n flights numbered 1 to n. Each booking
[first, last, seats] reserves seats seats on
every flight from first to last, inclusive.
Return a list answer of length n where
answer[i] is the total seats reserved on flight
i + 1.
Example 1
Input: bookings = [[1, 2, 10], [2, 3, 20],
[2, 5, 25]], n = 5
Output: [10, 55, 45, 25, 25]
Flight 2 gets 10 + 20 + 25 = 55.
Example 2
Input: bookings = [[1, 2, 10], [2, 2, 15]], n = 2
Output: [10, 25]
Example 3
Input: bookings = [[3, 3, 5]], n = 4
Output: [0, 0, 5, 0]
Constraints
- 1 ≤ n ≤ 2 · 10⁴
- 1 ≤ len(bookings) ≤ 2 · 10⁴
- 1 ≤ first ≤ last ≤ n
- 1 ≤ seats ≤ 10⁴