For this tilling2 problem
Can i have solution for this problem , with explanation
Recursive function for this problem should be something like this:
int noofways(int n,int m)
{
if(n==0)
return 1;
if(n<0)
return 0;
int way1=noofways(n-1,m);
int way2=noofways(n-m,m);
return (way1+way2)%1000000007;
}
However just by recursion, your code will not pass all the test cases and will give Time Limit Exceed error since the constraints are large. You need dynamic programming to solve this problem. So i would suggest you to attempt this problem after completing Dynamic Programming concepts.
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.