I am getting correct answer for the given test cases…is the logic wrong or is there some bug in the code i am passing only first test case?
Count Binary Strings
@aryamaan1011 your logic is incorrect!
you can add 0 to any previous string
so dp[0][i] = dp[0][i-1] + dp[1][i-1]
but you can add 1 only to previous strings ending with 0
so dp[1][i] = dp[0][i-1]
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.