Please tell me error in my code

#include
using namespace std;
int tilling(int n,int m)
{
if(n==1 || n==0)
{
return n;
}
if(m==0 || m==1)
{
return m;
}

int ans=tilling(n-1,m);
int ans1=tilling(n-m,m-1);
int ans2=ans+ans1;

return ans2;

}
int main() {
int t;
cin>>t;
int q=1;
int n,m;
while(q<=t)
{
cin>>n>>m;
int ans=tilling(n,m);
cout<<ans<<endl;
q++;
}

return 0;

}

this solution will give you tle as there are two recursion calls at every level, so in worst case there will be 2^n recursion calls. change you solution and use bottom-up dynamic programming

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.