Skip to content

Commit 6cde5e4

Browse files
authored
Add carPooling function for trip capacity validation
Implement carPooling function to check capacity.
1 parent e2fd604 commit 6cde5e4

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number[][]} trips
3+
* @param {number} capacity
4+
* @return {boolean}
5+
*/
6+
var carPooling = function(trips, capacity) {
7+
// trips[i] = [numPassengers, from, to]
8+
// nP 승객이 from에서 타서 to에서 내림
9+
let arr = new Array(1000).fill(0);
10+
for (let i = 0; i<trips.length; i++){
11+
let nP = trips[i][0];
12+
let from = trips[i][1];
13+
let to = trips[i][2];
14+
15+
arr[from] += np;
16+
arr[to] -= np;
17+
}
18+
19+
if (capacity)
20+
};

0 commit comments

Comments
 (0)