Showing tle in teastcase 1 3 4

what can i do to optimize this solution

@Piyush-Pandey-2580479718941914,
MEMOIZE!!!

how can i memorize the steps

@Piyush-Pandey-2580479718941914,
Just like we memoize any overlapping recursive function, have you studied dp?

no right now mastering recursion

@Piyush-Pandey-2580479718941914,
Then, you should leave this problem for now, come back to it when you have learned dp.