medium
Corporate Flight Bookings
There are n flights numbered 1..n. Each booking [first, last, seats] reserves seats on every flight from first to last inclusive. Return the total seats reserved on each flight.
Constraints
- 1 ≤ n ≤ 2 · 10^4
- 1 ≤ bookings.length ≤ 2 · 10^4
- 1 ≤ first ≤ last ≤ n
- 1 ≤ seats ≤ 10^4
Examples
in: bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
out: [10,55,45,25,25]
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.