TLE Facing While Running Code

Could You Please Look At the Code I think I have done right but don’t why I am facing TLE Problem

@vikram.keswani108
Your logic is correct and time complexity of your code is also good. I have tried different variations in your code, but It giving the same result with recusion. Try to solve it using iterative method. If it still won’t work, I’ll try to contact problem setter.

I am keeping the practice of the top down apporach I don’t want to go to bottom up approach please see if anything could be done here

hello @vikram.keswani108
as ashishek said ur logic is correct and time complexity is also fine.
there might be some issue with checker due to which is showing tle.
if possible pls share hackerblocks link for the problem i will check.

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.

The doubt was reopened. @vikram.keswani108 Is your doubt resolved? If so then please mark it 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.