Doubt-Class Assignment

Please explain, the intuition behind the solution of this question. How did you conclude that this question is the same as the print Fibonacci number question?

Hey @Shadilfarooque,
In this question, we are provided with a number n, we need to find the total number of distinct integers of length n, such that they consist of 2 distinct digits a and b (0<= digit <=9), such that the 2nd digit (b) doesn’t repeat.

Think of it like we need to fill n spots, where every spot has 2 options: a and b and no 2 consecutive spots have b.
We can do this by checking the element in previously filled spot.
If the previously filled spot has a, we can place either of a or b at present spot.
Else if the previously filled spot has b, we can only place a at present spot.

You can list and count the possible answers to observe that the pattern we are obtaining is same as that followed by fibonacci numbers. Try coding it out, you will observe the pattern. :slight_smile:

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.