Skip to content

Commit 7ac394b

Browse files
committed
update: 62
1 parent 8df3723 commit 7ac394b

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ This is the solutions collection of my LeetCode submissions, most of them are pr
4242
|55|[Jump Game](https://leetcode.com/problems/jump-game/) <sup>*</sup> | [JavaScript](./src/jump-game/res.js)|Medium|
4343
|56|[Merge Intervals](https://leetcode.com/problems/merge-intervals/) | [JavaScript](./src/merge-intervals/res.js)|Medium|
4444
|57|[Insert Interval](https://leetcode.com/problems/insert-interval/) | [JavaScript](./src/insert-interval/res.js)|Hard|
45+
|62|[Unique Paths](https://leetcode.com/problems/unique-paths/) | [JavaScript](./src/unique-paths/res.js)|Medium|
4546
|66|[Plus One](https://leetcode.com/problems/plus-one/) | [JavaScript](./src/plus-one/res.js)|Easy|
4647
|69|[Sqrt(x)](https://leetcode.com/problems/sqrtx/) | [JavaScript](./src/sqrtx/res.js)|Easy|
4748
|71|[Simplify Path](https://leetcode.com/problems/simplify-path/) | [JavaScript](./src/simplify-path/res.js)|Medium|

src/unique-paths/res.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number} m
3+
* @param {number} n
4+
* @return {number}
5+
*/
6+
var uniquePaths = function(m, n) {
7+
const list = [];
8+
for (let i = 0; i < n; i++) {
9+
list.push([]);
10+
for (let j = 0; j < m; j++) {
11+
if (i === 0 || j === 0) {
12+
list[i][j] = 1;
13+
} else {
14+
list[i][j] = Math.max(list[i-1][j] + list[i][j-1]);
15+
}
16+
}
17+
}
18+
19+
return list[n-1][m-1];
20+
};

0 commit comments

Comments
 (0)