Except for one test case,the other are showing TLE.
Please help me in correcting my code.
Code Resulting in TLE
Hey @paulayush2002, you are getting TLE because this problem requires a dynamic programming approach, which i can see that you haven’t used. I’ll suggest you to leave it for now and go on with rest as team will be shifting this problem in dp section 
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.