did not abel to get what is the problem is
Class assignment problem 123
Hello @Aug19APPPP0003,
In the question you have to print the count of strings of length n, that can be made using only a and b:
With a condition, that you cannot place b at consecutive positions.
Let’s understand with the help of an example:
3 //this is the no. of test cases and following are the values of n for different testcases
1
2
3
-
In the first testcase, the value of n is 1.
The possible strings of length 1 with a and b as characters are:
a, b i.e. 2 -
In the second testcase, n=2.
The possible strings of length 1 with a and b as characters are:
aa, ab, ba i.e. 3
bb is not included in the count as in this b are at consecutive position -
Similarly, for n=3 in the third testcase.
The possible strings of length 1 with a and b as characters are:
aaa, aba, baa, aab, bab i.e. 5
Now, considering the output format, the output will be:
#1 : 2
#2 : 3
#3 : 5
You can refer to the video, Count Binary Strings Hint from your course as it is a similar question.
Hope, this would help.
Give a like if you are satisfied.
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.