Given an array a, find the number of pairs such that a[i]<=a[j]+k where i<j? Constraints — size of array <=1e5 I tried to use the concept of merge sort the way we use it to count inversions in an unsorted array, but I am getting WA. Could you help how to approach this problem and if you can provide code it would be very helpful.
abusing ordered sets is fun