I am creating a program but it is giving time limit exceeded

Can you please check the code and give me some suggestions on how to optimise it.

Hello @sarthak_singhal your code is already optimsied as you are using the three pointer approach.
Your logic is correct as well
if wouldnt have passed all the test case if not optimised.
Happy Learning!!

Hello @sarthak_singhal i have corrected your code and commented the mistake.
you can see the code and ask here if you dont understand anything:


Happy Learning!!

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.