2 line code xD (in C)


int uniquePaths(int A, int B)
if(A==1 || B==1) return 1;
else return uniquePaths(A-1, B) + uniquePaths(A, B-1);


You can still optimize this. You are calculating some subproblems repeatedly. Think how can you cut short them.


Please don’t put the solution in the problem discussion please.Put it in the solution discussion.


We can use the logic of LCS:


You don’t need a 2d array here, 1d array is good enough.