I have implemented sliding window method in this problem, but there's TLE for testcase 9 . This is the link. I know the solution is wrong, but I want to know where I am going wrong, so that I shouldn't repeat same mistake again. It would be nice if someone of you will guide me to resolve this issue. Thanking in advance.

It's clear that, your solution has a complexity of O(n^2). Which is not enough to pass the test cases. This problem is very easy to solve using two pointer algorithm. I'm not sure if you are familiar with this algorithm or not. May be you have implemented this algorithm in a wrong way. Try 16375131.

Thanks froghramar

Hello Shyam,

Thanks mate, I would surely get help from you. I hope it will improve my programming skills faster than practicing alone.