Skip to content

Commit f7e9e72

Browse files
authored
Merge pull request gzc426#782 from MMzhe/patch-63
Create sourcema.md
2 parents b5e7f4e + a3d0cf4 commit f7e9e72

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

2019.01.30-leetcode62/sourcema.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# LeetCode 62
2+
class Solution {
3+
public int uniquePaths(int m, int n) {
4+
if (m == 1 || n == 1) {
5+
return 1;
6+
}
7+
int[][] dp = new int[m][n];
8+
for (int i = 1; i < n; i++) {
9+
dp[0][i]=1;
10+
}
11+
for (int i = 1; i < m; i++) {
12+
dp[i][0]=1;
13+
}
14+
for (int i = 1; i < m; i++) {
15+
for (int j = 1; j < n; j++) {
16+
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
17+
}
18+
}
19+
return dp[m - 1][n - 1];
20+
}
21+
}

0 commit comments

Comments
 (0)