Recursion-Class Assignment TLE

Is it possible to solve this using DP? Code works fine for smaller test cases

this is a dp Q…

int a[n],b[n];
a[0]=1,b[0]=1;
for(int i=1;i<n;i++)
{
a[i]=a[i-1]+b[i-1];
b[i]=a[i-1];
}
return a[n-1]+b[n-1];

try to understand the dp .

Thank you, I understood the relation used, but how do I think it myself?

https://www.quora.com/How-should-I-explain-dynamic-programming-to-a-4-year-old/answer/Jonathan-Paulson
may you get some motivation :stuck_out_tongue: