题目
这里有 n 个航班,它们分别从 1 到 n 进行编号。
有一份航班预订表 bookings ,表中第 i 条预订记录 bookings[i] = [firsti, lasti, seatsi]
意味着在从 firsti 到 lasti (包含 firsti 和 lasti )的 每个航班 上预订了 seatsi 个座位。
请你返回一个长度为 n 的数组 answer,其中 answer[i]
是航班 i 上预订的座位总数。
差分
在这里预订列表,其实是一个区间的增量。
而这里的答案便是把这些增量累加到一个数组中。
参考资料
- 1109. 航班预订统计 (opens new window)
- 官方题解 (opens new window)