1109. 航班预订统计
1109. 航班预订统计
class Solution {
public:
vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) {
vector<int> sum(n,0);
for(int i = 0;i < bookings.size();i ++)
{
int st = bookings[i][0] - 1,ed = bookings[i][1] - 1,num = bookings[i][2];
sum[st] += num;
if(ed + 1 < n)sum[ed + 1] -= num;
}
for(int i = 1;i < sum.size();i ++)
{
sum[i] += sum[i - 1];
}
return sum;
}
};