每日一题:https://leetcode.cn/problems/car-pooling/
题目链接:https://leetcode.cn/problems/car-pooling/
bool carPooling(int** trips, int tripsSize, int* tripsColSize, int capacity) {
int arr[1100];
int max=0;
for(int i=0;i<tripsSize;i++){
max=max>trips[i][2]?max:trips[i][2];
arr[trips[i][1]]+=trips[i][0];
arr[trips[i][2]]-=trips[i][0];
}
for(int i=1;i<max+10;i++){
arr[i]+=arr[i-1];
if(arr[i-1]>capacity){
return false;
}
}return true;
}