It's giving TLE. Please check my code

@gaganpreetsachdev1
Your solution is purely recursive because of which certain states are being computed time and again.
If you familiar with the concept of dynamic programming, use dp to optimize this solution. If not, wait till you get acquainted with the topic and then try the question.

If my solution was able to answer your query, please mark the doubt as resolved.

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.