int Solution::uniquePaths(int A, int B) {
if(A==1 || B==1){
return 1;
}
return uniquePaths(A-1,B) + uniquePaths(A,B-1);
}
Very very simple C++ solution in 2 lines
avi_bhardwaj
#1
n-k_972
#2
why its working?? it should be like
if(A==1&&B==1) return 1;
if(A<=1||B<=1) return 0;
because going to first row,does not mean we reached the target cell… it has to be both index
sagar-sikchi
#3
Very very very simple solution in Java or C++
return (A == 1 || B == 1) ? 1 : uniquePaths(A - 1, B) + uniquePaths(A, B - 1);