I need some help with this problem
Actually, I think I have got quite a hold of it. What I can't get my head around is as there may be n(n-1)/2 possible pairs at the max, how can I take all these possible pairs in less than O(N^2) time? The constraints clearly mean that O(N^2) won't do. Or is there some way to bypass this calculation? (which I am quite sure there isn't)