Seat Totals Across Inclusive Flight Bookings

Quick Overview

Seat Totals Across Inclusive Flight Bookings. Flights are labeled1 through n. A booking [first,last,seats] reserves seats seats on every flight from first through last, inclusive.

Seat Totals Across Inclusive Flight Bookings

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem Flights are labeled 1 through n. A booking `[first,last,seats]` reserves seats seats on every flight from first through last, inclusive. Return n totals in flight-label order: output index i-1 contains the total for flight i. ```cpp class Solution { public: vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n); }; ``` ### Examples **Example 1:** ```text Input: bookings = [[1,3,4],[2,2,7]], n = 3 Output: [4,11,4] Explanation: The middle flight receives both reservations; the others receive4 seats each. ``` **Example 2:** ```text Input: bookings = [[2,4,3]], n = 4 Output: [0,3,3,3] Explanation: Flight1 has no booking; flights2 through4 each receive3 seats. ``` ### Constraints - There are 1 to 20000 flights and 1 to 20000 bookings. - Every booking has three entries with `1 <= first <= last <= n`. - Each seats value is an integer between 1 and 10000. ### Contract considerations Flight labels start at 1, while returned array indices start at 0. ```hint Read the boundary condition Are both booking endpoints included, and which returned position corresponds to flight 1? ``` ### Boundary reminders Flight labels start at 1, while returned array indices start at 0.

Overview: Seat Totals Across Inclusive Flight Bookings. Flights are labeled1 through n. A booking [first,last,seats] reserves seats seats on every flight from first through last, inclusive.

Microsoft logo
Microsoft
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

Flights are labeled 1 through n. A booking [first,last,seats] reserves seats seats on every flight from first through last, inclusive. Return n totals in flight-label order: output index i-1 contains the total for flight i.

class Solution {
public:
    vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n);
};

Examples

Example 1:

Input: bookings = [[1,3,4],[2,2,7]], n = 3
Output: [4,11,4]
Explanation: The middle flight receives both reservations; the others receive4 seats each.

Example 2:

Input: bookings = [[2,4,3]], n = 4
Output: [0,3,3,3]
Explanation: Flight1 has no booking; flights2 through4 each receive3 seats.

Constraints

  • There are 1 to 20000 flights and 1 to 20000 bookings.
  • Every booking has three entries with 1 <= first <= last <= n .
  • Each seats value is an integer between 1 and 10000.

Contract considerations

Flight labels start at 1, while returned array indices start at 0.

Boundary reminders

Flight labels start at 1, while returned array indices start at 0.