Skip to content

Commit db7edda

Browse files
committed
unique-paths
1 parent 3bb51b9 commit db7edda

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

unique-paths/chjung99.java

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

0 commit comments

Comments
 (0)