this is not a dp problem
Why this problem is given in dp section?
This is a dp problem only.
long long int countStrings(int n)
{
long long int a[n+1], b[n+1];
a[1] = b[1] = 1;
for (int i = 2; i <= n; i++)
{
a[i] = a[i-1] + b[i-1];
b[i] = a[i-1];
}
return a[n] + b[n];
}
This is dp only
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.