Getting TLE in some of test case

hello @siddhant_samal

the recursive solution has exponential time complexity thats why u r getting tle .

so to improve the time complexity use dynamic programming

Sir ,but I have not yet started the DP section and ,this Question is under recursion section only

ur recursive solution is correct but to pass all test cases u need to use dp.

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.

I have made the recursive code but able to apply dp …as I am new to dynamic programming…could you fix the code https://ide.codingblocks.com/s/364846

Hey @siddhant_samal check this, will apply dp by this method.

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.