My issue
Recursion
My code
#include <iostream>
using namespace std;
int find(int n,int l){
if(n==0)return 1;
if (n < 0 || n > l) {
return 0;
}
if(n-l+1 >=0)return 1;
return find(n-2,l)+find(n-4,l);
}
int main() {
// your code goes here
int m;
cin>>m;
for(int i=0;i<m;i++){
int n,l;
cin>>n>>l;
int ans=find(n,l);
cout<<ans<<endl;
}
return 0;
}
Learning course: Dynamic programming
Problem Link: Practice Problem in - CodeChef