class Solution {

public:

int uniquePaths(int m, int n) {

int N = n + m - 2;// how much steps we need to do

int k = m - 1; // number of steps that need to go down

double res = 1;

// here we calculate the total possible path number

// Combination(N, k) = Combination(N, N - k)

for (int i = 1; i <= k; i++)

res = res * (N - i + 1) / i;

return (int)res;

}

};

if I change the res = res * (N - i + 1) / i to res = res * (N - k + i) / i then the code got accepted