Corporate Flight Bookings Problem Statement
You are given an array/list BOOKINGS
representing the booking details of 'N' flights from 1 to 'N'. Each booking detail consists of three positive integers: [first, last, seats]. This indicates a booking from flights 'first' through 'last' (inclusive) with 'seats' reserved for each flight within this range.
Your task is to return an array/list ANSWER
of length 'N', where ANSWER[i]
denotes the total number of seats reserved for the i-th flight.
Input:
The first line contains an integer ‘T’ representing the number of test cases. The first line of each test case contains two space-separated integers ‘N’ and ‘M’, indicating the number of flights and the number of booking details, respectively. Each of the next ‘M’ lines contains three space-separated integers: [first, last, seats], which represent the booking details.
Output:
For each test case, output ‘N’ space-separated integers denoting the elements of the ANSWER
array/list. Output each test case on a separate line.
Example:
Input:
2
5 3
1 2 10
2 3 20
2 5 25
3 2
1 1 10
2 2 20
Output:
10 55 45 25 25
10 20
Explanation:
For the first test case, the seat reservation for flights is as follows: flight 1 has 10 seats, flight 2 has 55 seats, flight 3 has 45 seats, etc.
Constraints:
1 <= T <= 50
1 <= N, M <= 104
1 <= first, last <= N
1 <= seats <= 103
Note: The expected output is not required to be printed; focus on implementing the function only.


Given flight booking details, calculate total seats reserved for each flight.
Iterate through each booking detail and update the total seats reserved for each flight within the range
Use an array to sto...read more

Popular interview questions of Software Developer Intern
Reviews
Interviews
Salaries
Users/Month