每日一题:https://leetcode.cn/problems/corporate-flight-bookings/
题目链接:https://leetcode.cn/problems/corporate-flight-bookings/
int* corpFlightBookings(int** bookings, int bookingsSize, int* bookingsColSize, int n, int* returnSize) {
int* arr = malloc(sizeof(int) * n);
memset(arr, 0, sizeof(int) * n);
for(int i=0;i<bookingsSize;i++){
arr[bookings[i][0]-1]+=bookings[i][2];
}
for(int i=0;i<bookingsSize;i++){
if(bookings[i][1]<n)
arr[bookings[i][1]]-=bookings[i][2];
}
for(int i=1;i<n;i++){
arr[i]+=arr[i-1];
}
*returnSize=n;
return arr;
}