I have checked for every giving correct plz check

not single test case is passing what is wrong

Hello @mohitsingh what is the logic that you are using?

@mohitsingh you have to use the dynamic programming in case if you are doing with recursion.
but more or less you can solve this question in more simpler way like read this:
you can approach it in the way actually there are 2 ways in which i have done this question one is the fibonacci way and the other is the way which we can do by DP.
In the dp way we will check for the recusrion calls and then there we will also check if there are not two consecutive b’s if there are 2 consecutive b’s then we will send the a in the recusrion call and otherwise we will make two recursion calls for the both ‘a’ and ‘b’.
Here for your reference i am attaching both the codes.
fibonacci one:


and using the DP one:

if you have any doubt you can ask here:
Happy Learning!!

sir ye recusrsion me hai ques not in the dp part

in which test cases code is failing plz tell me approach is simple by using recursion im taking all the possibilite when n>=2 and when n<2

@mohitsingh some questions in the recursion part will only pass test cases if you will apply DP in it.
So kindly leave the question until you do DP.
Otherwise I think that fibonacci’s solution can be used without DP.
But you have to use dp to store the results.
Otherwise it will reevaluate for already evaluated test cases.

I have asked team to put these questions in DP part only so that you don’t suffer from this thing then.

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.