more simple?


  • 0
    Q
    class Solution {
    public:
        int uniquePaths(int m, int n) {
            vector<int>v(m,1);
            for(int i = 1 ; i < n ; ++i)
                for(int j = 1 ; j < m ; ++j)
                    v[j] += v[j-1] ;
            return v[m-1];
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.