Code Room
CodingMediumcod-g666
Subject Sweep lineLevel Entry–Mid~18 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

There are `n` flights labelled 1 to n. You are given `bookings` where bookings[i] = [first, last, seats] meaning `seats` seats were reserved on every flight from `first` to `last` inclusive. Return an array of length n where the i-th element is the total seats reserved on flight i+1. With up to 2*10^4 bookings and n up to 2*10^4, apply each booking as an O(1) range update on a difference array and take a prefix sum at the end.

Implement
corp_flight_bookings(bookings: list[list[int]], n: int) → list[int]
Examples
in[[[1,2,10],[2,3,20],[2,5,25]],5]out[10,55,45,25,25]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.