Showing TLE in more than one cases

How do i improve this code?

Hello @priyamthakuria27
use dynamic programming to make it more efficient

this question is under recursion challenge problems.

yeah i know,but u cannot pass all test case just by using recusion.
use dp to make it O(n) solution

Okay.
thank you for that :’)