Skip to content

Commit 81b46d3

Browse files
committed
ok
1 parent d8c4b7c commit 81b46d3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/com/leetcode/Main62.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.leetcode;
2+
3+
/**
4+
* 52. 不同路径
5+
*
6+
*/
7+
public class Main62 {
8+
public int uniquePaths(int m, int n) {
9+
int[][] dp = new int[m][n];
10+
for(int i = 0; i < m; i++) {
11+
for(int j = 0; j < n; j++) {
12+
if(i == 0 || j == 0)
13+
dp[i][j] = 1;
14+
else
15+
dp[i][j] = dp[i][j-1] + dp[i-1][j];
16+
}
17+
}
18+
return dp[m-1][n-1];
19+
}
20+
}

0 commit comments

Comments
 (0)