中级农民
- 积分
- 101
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2014-8-18
- 最后登录
- 1970-1-1
|
- public class Solution {
- public int uniquePaths(int m, int n) {
-
- if(m==0 || n==0) return 0;
- if(m==1 || n==1) return 1;
- int[] path = new int[m-1];
- path[0] = 2;
- for(int i=1;i<path.length;i++){
- path[i] = path[i-1] + 1;
- }
- for(int j=2;j<n;j++){
- path[0] = path[0] + 1;
- for(int i=1;i<path.length;i++){
- path[i] = path[i] + path[i-1];
- }
- }
- return path[m-2];
- }
- }
复制代码
|
|