Skip to content

Commit d254bb9

Browse files
committedAug 1, 2019
add 1094 js
1 parent 2ec03fe commit d254bb9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ LeetCode
431431
|1090|[Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels/) | c | [c++](./src/1090-Largest-Values-From-Labels/1090.cpp) |[python](./src/1090-Largest-Values-From-Labels/1090.py)|||Medium|
432432
|1091|[Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix/) | c | [c++](./src/1091-Shortest-Path-in-Binary-Matrix/1091.cpp) |[python](./src/1091-Shortest-Path-in-Binary-Matrix/1091.py)|[go](./src/1091-Shortest-Path-in-Binary-Matrix/1091.go)|[js](./src/1091-Shortest-Path-in-Binary-Matrix/1091.js)|Medium|
433433
|1093|[Statistics from a Large Sample](https://leetcode.com/problems/statistics-from-a-large-sample/) | c | [c++](./src/1093-Statistics-from-a-Large-Sample/1093.cpp) |[python](./src/1093-Statistics-from-a-Large-Sample/1093.py)|[go](./src/1093-Statistics-from-a-Large-Sample/1093.go)|[js](./src/1093-Statistics-from-a-Large-Sample/1093.js)|Medium|
434-
|1094|[Car Pooling](https://leetcode.com/problems/car-pooling/) | c | [c++](./src/1094-Car-Pooling/1094.cpp) |[python](./src/1094-Car-Pooling/1094.py)|[go](./src/1094-Car-Pooling/1094.go)||Medium|
434+
|1094|[Car Pooling](https://leetcode.com/problems/car-pooling/) | c | [c++](./src/1094-Car-Pooling/1094.cpp) |[python](./src/1094-Car-Pooling/1094.py)|[go](./src/1094-Car-Pooling/1094.go)|[js](./src/1094-Car-Pooling/1094.js)|Medium|
435435
|1095|[Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array/) | c | [c++](./src/1095-Find-in-Mountain-Array/1095.cpp) |[python](./src/1095-Find-in-Mountain-Array/1095.py)|[go](./src/1095-Find-in-Mountain-Array/1095.go)||Hard|
436436
|1096|[Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii/) | c | [c++](./src/1096-Brace-Expansion-II/1096.cpp) |[python](./src/1096-Brace-Expansion-II/1096.py)|[go](./src/1096-Brace-Expansion-II/1096.go)||Hard|
437437
|1099|[Two Sum Less Than K](https://leetcode.com/contest/biweekly-contest-3/problems/two-sum-less-than-k/) | c | [c++](./src/1099-Two-Sum-Less-Than-K/1099.cpp) |[python](./src/1099-Two-Sum-Less-Than-K/1099.py)|[go](./src/1099-Two-Sum-Less-Than-K/1099.go)||Easy|

‎src/1094-Car-Pooling/1094.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var carPooling = function(trips, capacity) {
2+
var tmp = [];
3+
for (let v of trips) {
4+
tmp.push([v[1], v[0]]);
5+
tmp.push([v[2], -v[0]]);
6+
}
7+
tmp.sort(function(a, b){
8+
if (a[0] == b[0]) return a[1] - b[1];
9+
else return a[0] - b[0];
10+
});
11+
12+
var res = 0;
13+
for (let v of tmp) {
14+
res += v[1];
15+
if (res > capacity) return false;
16+
}
17+
return true;
18+
};

0 commit comments

Comments
 (0)
Please sign in to comment.