Tiling problem recursion

getting compile error

because at line no 12
you forgot to close the braces

correct one
return tile(n,ma-1)%m+tile(n-ma,ma)%m;

but we have to take mood again na of whole ans that is returned?

getting run error for 3 cases

yes you also have to take mod with whole ans again

still getting run error for testcases

return (tile(n,ma-1)%m+tile(n-ma,ma%m))%m;

Above is your code,
you have done two mistakes:

  1. your recursion is wrong
  2. you misplaced “m” here

Anyways we all are learning…
Do these corrections:
return (tile(n-1,ma)+tile(n-ma,ma))%m;

But this is not enough , you still get TLE, because after all you have to do memoization in this question…
So, ADVICE:: do it after you are familiar with memoization / dp

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.