LeetCode.62-unique-paths

LeetCode.62-unique-paths

思路:https://segmentfault.com/a/1190000016315625

class Solution {
    public int uniquePaths(int m, int n) {
        
        int[][] paths = new int[m][n];
        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                if(i==0||j==0){
                    paths[i][j] = 1;
                }else{
                    paths[i][j] = paths[i-1][j]+paths[i][j-1]
                }             
            }      
        }
        return paths[m-1][n-1]
    }
}

 

posted @ 2019-10-30 12:33  李荣先辈Java  阅读(124)  评论(0编辑  收藏  举报