i don’t under stand can you provide pseudo code
Please provide me pseudo code
recursive approach: f(n,m)=f(n-1,m)+f(n-m,m)…base case if n=0 return 1 and if n<0 return 0.
int answer(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;
}
This question would not pass all the test cases with recursion.
It will show TLE for few cases.
Dynamic Programming approach is the required to pass the rest of the test cases.
You can try and implement it through DP, if you face any problems, please reply on this thread. I would love to help you.