class Solution {
public:
bool carPooling(vector<vector<int>>& trips, int capacity) {
vector<int> data(1000, 0);
for(int i = 0; i < trips.size(); i++){
data[trips[i][1]-1] += trips[i][0];
data[trips[i][2] - 1] -= trips[i][0];
}
int c = 0;
for(int i = 0; i < data.size(); i++){
c += data[i];
if(c > capacity)
return false;
}
return true;
}
};