Declare and implement a function called countArrayInversions
that receives an array of Int values and returns a count of the number of
inversions in the array. An inversion is a pair of indices i and j
where i < j but A[i] > A[j], for the array A.
Note: this can be completed with a nested for loop, but a faster algorithm can be achieved using recursion and a modified merge sort. If you choose to do this, note that you cannot modify the input array, so you may need to copy it. You may also want to write a private helper function, like so:
Stuck? You may find these lessons helpful: