Sir, getting WA in for few test cases with this top down approach. I saw the hint video too, but there it is mentioned to return 2 for base case of n=1, which doesn’t satisfy according to recursive calls.
Count Number of Distinct string without consecutive ones
used memoisation to solve the problem have a look in case of problem ping me
Okay, I tried memoisation in bottom up approach, it got accepted. Though for the Top down approach, I was using int instead of long long, so now working fine both the ways
1 Like