Skip to content

Commit 282a143

Browse files
committed
Create 62.不同路径.js
1 parent 1001a4a commit 282a143

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

62.不同路径.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {number} m
3+
* @param {number} n
4+
* @return {number}
5+
*/
6+
var uniquePaths = function(m, n) {
7+
const dp = [1];
8+
for (let i = 0; i < m; i++) {
9+
for (let j = 0; j < n; j++) {
10+
dp[j] = (dp[j] || 0) + (dp[j - 1] || 0);
11+
}
12+
}
13+
return dp[n - 1];
14+
};

0 commit comments

Comments
 (0)