Count number of binary strings


i have written recursive solution.
anyone help me how to use memoization to optimize code

what you are doing is coreect , but the thing is you are making the strings, you only have to count the strings, logic is correct!

i have figured out dp solution. i am asking for how to implement memoization to optimize code ?
please help. i am unable to figure out.


bottom up dp approach


you code with memoisation , this is how we implement memoisation

above memoised code not working.

the ouput should be memo[0] not cnt,

cout<<memo[0]<<endl;

give 0 for every test case.
still not working.

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.

1 Like