题解 | #不同路径的数目(一)#
不同路径的数目(一)
http://www.nowcoder.com/practice/166eaff8439d4cd898e3ba933fbc6358
public static int uniquePaths (int m, int n) {
int[][] dp = new int[m+1][n+1];
for (int i = dp.length - 1; i >= 0; i--) {
for (int j = dp[i].length - 1; j >= 0; j--) {
if(i>=m||j>=n){
dp[i][j] = 0;
}else if(i==m-1&&j==n-1){
dp[i][j] = 1;
}else{
dp[i][j] = dp[i+1][j]+dp[i][j+1];
}
}
}
return dp[0][0];
}