### faisal_sohail's blog

By faisal_sohail, history, 7 weeks ago,

hello there, i am facing problem in solving dp using top down approach.

problem 1


i tried to solve this problem using DP Top down approach (recursively with memoization). got Accepted when submitted this_solution while it gave TLE for other_solution i tried to figure out the reason behind but failed . curious to know, why my second solution gave TLE. 

 problem 2:


i tried to solve this_problem of Atcoder using top_down approach,but it shows TLE for two sub-tasks> my_solution_link am i missing any edge case or it just because of recursion or Python?

any help is highly appreciated. along with that i will be glad if u would do code review and suggest ways to make my coding more effective and readable

Thanks a ton in advance. Happy coding

• -1

 » 7 weeks ago, # |   0 Sir, I am not good in competitive programming, but I know that in python there is limit in recursion, so try to make iterative. And if you want to do it in recursion then try in cpp.
•  » » 7 weeks ago, # ^ | ← Rev. 2 →   0 hey buddy @Rishi_Kant ,i know that . see my second solution even in the first case ,if recursion depth would have been the problem then it should have returned RE and not TLE.anyways thanks for responding