Skip to content

Practice Corporate Flight Bookings

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1109
LeetCode Problem

Corporate Flight Bookings

Problem Statement

There are n flights that are labeled from 1 to n. You are given an array of flight bookings bookings, where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights firsti through lasti (inclusive) with seatsi seats reserved for each flight in the range. Return an array answer of length n, where answer[i] is the total number of seats reserved for flight i.

Source: Corporate Flight Bookings on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5
Output
[10,55,45,25,25]

# Example 2

Input
bookings = [[1,2,10],[2,2,15]], n = 2
Output
[10,25]

Constraints

1 <= n <= 2 * 10^4
1 <= bookings.length <= 2 * 10^4
bookings[i].length == 3
1 <= firsti <= lasti <= n
1 <= seatsi <= 10^4

Related LeetCode Problems

Practice more problems similar to Corporate Flight Bookings.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.