• + 1 comment

    Believe it or not there is a divide and conquer solution in O(n*log(n)). Find inversions in O(n*logn) using a merge sort variant in the accumulation array a where a[i] = sum of all elements from 0 to i.