This should be the base cases right?

if (n == 0) {
return 1;
}

if (n == 1){
    if (n - 1 == 0){
        return 2;
    }
    else{
        return 0;
    }
}

Binary string can be only 0 and 1 , but not 1 and 0 right?

hello @udatta

both are same thing 0 and 1 or 1 and 0 .

no need of inner if else.
simply write if n==1 return 2;

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.