class Solution {
public:vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) {
vector<int>res(n,0);for(auto book:bookings){
res[book[0]-1]+=book[2];if(book[1]<n)res[book[1]]-=book[2];}for(int i=1;i<n;i++){
res[i]+=res[i-1];}return res;}
};
class Solution {
public:int lowbit(int x){
return x&(-x);}vector<int>C;void update(int i, int k){
while(i<=C.size()-1){
C[i]+=k;i+=lowbit(i);}}int getsum(int i){
int sum=0;while(i>0){
sum+=C[i];i-=lowbit(i);}return sum;}vector<int> corpFlightBookings(vector<vector<int>>& bookings, int n) {
C.resize(n+1,0);vector<int>res(n,0);for(auto book:bookings){
update(book[0],book[2]);if(book[1]<n+1)update(book[1]+1,-book[2]);}for(int i=1;i<=n;i++){
res[i-1]=getsum(i);}return res;}
};