Implement inversion counting with global variable
Implement inversion counting with global variable

A global counter variable is increased every time
merge_and_count_split encounters an element in the second array
that is smaller than an element in the first array. The count is
increased by the number of elements remaining in the first array,
since the element is necessarily smaller than all of them when the
arrays are sorted. This allows inversions to be counted in linear
time, making the overall algorithm O(nlogn) when the recursive
calls to sort are included.

timpel/stanford-algs,timpel/stanford-algs