【leetcode】62. 不同路径

int uniquePaths(int m, int n){
    int* arr=(int*)calloc(n,sizeof(int));
    arr[n-1]=1;
    int i;
    while(m-->0){
        for(i=n-1; i>=0; i--){
            arr[i]+=(i+1<n)?arr[i+1] :0;
        }
    }
    return *arr;
}

 

posted @ 2020-12-11 12:21  温暖了寂寞  阅读(50)  评论(0编辑  收藏  举报