Recursive soln?

what will be the recursive solution to it ???

@chemant077 It is very similar to Tilling problem 1 whose lecture video is already there in your playlist.
Recursive solution can be something like this:
Use the recursive approach: f(n,m)=f(n-1,m)+f(n-m,m)…take the base case that if n=0 return 1 and if n<0 return 0.

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;
}

But note that the recursive solution will not pass all the test cases. Since the constraints are large it would give Time Limit Exceed error. This question is actually of Dynamic Programming. I would suggest you to attempt this question after completing dynamic programming.

can you explain me n-m logic

Refer Tilling problem 1 video from your playlist and relate that with this. You will understand it well after that.

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.