Corporate Flight Bookings Problem
Corporate Flight Bookings Problem — ExecCode Medium DSA Practice
Solve the Corporate Flight Bookings problem on ExecCode. Free online medium DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
There are n flights numbered 1 to n. Each booking [first, last, seats] adds seats to every flight from first to last inclusive. Return an array of total seats reserved on each flight after all bookings.
Examples
Input bookings = [[1, 2, 10], [2, 3, 20], [2, 5, 25], [4, 6, 15]], n = 6; Output [10, 55, 45, 40, 40, 15]. Input bookings = [[1, 2, 10], [2, 2, 15]], n = 5; Output [10, 25, 0, 0, 0]. Input bookings = [[1, 4, 20]], n = 4; Output [20, 20, 20, 20]
Constraints
1 ≤ n ≤ 2×10⁴ 1 ≤ bookings.length ≤ 2×10⁴ 1 ≤ firsti ≤ lasti ≤ n 1 ≤ seatsi ≤ 10⁴
Practice Corporate Flight Bookings free on ExecCode. Browse DSA problems, topic map, and placement guides.