Code RoomFlight seat reservations
MediumPrep Room Coding #1232

Flight seat reservations

CodingAlgorithms & data structuresEntry–Mid~18 min

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.

0:00 of about 18 min
InputExpectedGot
[[[1,2,10],[2,3,20],[2,5,25]],5][10,55,45,25,25]not run yetsample