We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c76811 commit 196758fCopy full SHA for 196758f
1094-car-pooling.js
@@ -1,3 +1,26 @@
1
+/**
2
+ * @param {number[][]} trips
3
+ * @param {number} capacity
4
+ * @return {boolean}
5
+ */
6
+const carPooling = function(trips, capacity) {
7
+ const arr = Array(1001).fill(0)
8
+ for(const [num, s, e] of trips) {
9
+ arr[s] += num
10
+ arr[e] -= num
11
+ }
12
+ for(let i = 1; i < 1001; i++) {
13
+ arr[i] += arr[i - 1]
14
15
+
16
+ for(let e of arr) {
17
+ if(e > capacity) return false
18
19
+ return true
20
+};
21
22
+// another
23
24
/**
25
* @param {number[][]} trips
26
* @param {number} capacity
0 commit comments