Time limit exceeded

I am doing this question using recursion but getting time limit exceeded while submitting.Please suggest some correction in my recursive code.

@sukhwinder9813 Constraints are large and with recursion this problem will give TLE for large test cases.
You have to solve it with Dynamic Programming. Only then it would pass all the test cases. I would suggest you to return to this question after completing Dynamic Programming lectures.

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.