The expected of A = 0 and B = 0 is 1 and I think that it is wrong
Expected output A = 0, B = 08 is wrong
C++ [O(n), O(1)] Solution; Time and Space efficient solution
// Efficient Binomial Coefficient calculation function
// It outputs value of (nCk)
int C(int n, int k)
{
int res = 1;
k = min(k, n-k);
for (int i = 0; i < k; ++i)
{
res *= (n - i);
res /= (i + 1);
}
return res;
}
int Solution::uniquePaths(int A, int B)
{
if(A >= 0 && B >= 0)
{
if(max(A, B) == 1)
return 1;
if(A*B == 0)
return 0;
return C(A+B-2, B-1);
}
}