Plz help it gives TTTLLLEEE

plz help it gives TTTLLLEEE …

Hello @t.prateek98 what is the logic that you are using?

Hello @t.prateek98 your logic and implementation both are correct but for the test cases for which it is giving TLE because the are very large as you can see the constraints,so thats why you should iuse the concept of maximum window trick that.
for your reference i am attaching the code for that implementation:


if you have any doubt you can ask here:
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.