Can anyone please explain the solution


#1

Can anyone please explain the solution


#2

forget from the recursion calls, look at every cell in the matrix, you set value for every cell just once, so simply you have R*C operations.
i agree that this solution is specific for this question (not so general), but there are other ways to calculate recursive programs.