Grid Unique Paths

 https://www.interviewbit.com/problems/grid-unique-paths/

int Solution::uniquePaths(int N, int M) {
    long long ans = 1;
    for (int i = M; i < (N + M - 1); i++) {
        ans *= i;
        ans /= (i - M + 1);
    }
    return ans;
}

 

Comments

Popular posts from this blog

Perfect Peak of Array

Is Rectangle?

Sort array with squares!