Will the base case be if(n<=2) return n-1;

Will the base case be if(n<=2) return n-1;

for length 1 we have two options 0 or 1
for length 2 we have 3 options
00
01
10

hence correct base will be
if(n<=0)return 0;
if(n<=2) return n+1;

Okayy Sir, Thanks for this.

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.