Pairs with Difference less than K

@aryanc403 plz help in this question…

How your approach is better than mine ? can u explain with some example :slight_smile:

I meant the time complexity of your sliding window algorithm may vary a lot from test case to test case. It will go sometimes till O(N), sometimes it will go till O(NlogN) and maybe a bit higher than that. I hope you can understand the variation of time complexity using sliding window where there is not a fixed window size.

Array bhai, Sorting itself is O(n log n)
So, even if your actual algorithm runs in lesser time.
Overall time Complexity will be O(n log n)

I am speaking about the time complexity of the sliding window algorithm and binary search only.