this is o(n) complexity yet all testcases are not being passed
No of binary string : recursion
This is because you are not checking whether the last digit assigned is 1 or 0 and giving all calls for equal chances to 0 and 1 .
also you are not making use of yout array if for the same whether you have the answer or not.
Here for your refernce i am attaching the correct code:
if you have any doubt you can ask here:
HappyLearning !!
yeah but I am saving the digits ending with 0 or 1 separately so I don’t need to check
https://ide.codingblocks.com/s/385370 here I have used the araay too and still not all testcases are being passed
@singhsimran567 i agree but that is not the major case.
as the test cases are larger you have to apply dynamic programming here
and you are not doing that.
You can do this question with fibonacci pattern as well.
yes but in this code i did use DP but still isn’t hepling
Hello @singhsimran567 i have corrected your code and now it is passing every test case:
you have to use long long int instead of int.
try to submit now.
Happy Learning!!
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.