Time limit exceeded in test cases. Please suggest a faster approach

Hello @gautam74 check this code:

can you please explain how you were able to reduce the time

since the code is essentially same except for the define statement

@gautam74 check this :

i have commented major mistakes:
i think that were silly only.

thanks a lot for explaining.

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.