sir im getting tle for two test cases , pls tell me how can i improve my solution
Count number of binary strings
Hey @piyush_666 notice it’s giving Fibonacci number. Also if Fibonacci link is not understandable to you, try to use dynamic programming.
sir but this is a simple question of recursion , then why do we need to use dp
why its not passing all the testcases for the code which prateek bhaiya provided in class.
Prateek bhaiya explained concept right. What you have to do is
This , store calculated values in an array name dp. So that you don’t recall for the same values multiple times. Thus avoiding TLE.
See constraints. If you will do it only using recursion you will get TLE. Hope this will help you.
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.