int uniquePaths(int A, int B)
{
if(A==1 || B==1) return 1;
else return uniquePaths(A-1, B) + uniquePaths(A, B-1);
}
2 line code xD (in C)
o1jrsuneww
#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.