CLASS ASSIGNMENT: unclear problem

Could not understand the problem, please explain the problem statement along with a test case

Think of it same as the question as no two consecutive ones. Let suppose you have 2 digits and no two consecutive same digits are allowed. So it is basically same as not having to have 2 ones if you have 0,1 as your digits.
This problem done using this logic
The sample one is given like
Test case =3
n=1
n=2
n=3
make a function n_digits and pass the value of n in the function
inside the function declare two array inside the function int a[n],int b[n]
and mark index 0 of both the array is 1
like
a[0]=1;
b[0]=1;
now apply a loop from i=1 to upto <=n
and do
a[i]=a[i-1]+b[i-1];
b[i]=a[i-1];
and return
a[n-1]+b[n-1];
do dry run on this logic.

1 Like

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.