Leetcode 775: Global and local inversions solution
When nums[i] > nums[j], it is global inversion. Local inversion is special case of global inversion with j=i+1 Consider the array: [0,1,2,3,4,5] If i swap a random element by 2 positions (either to left or right). I will always create 2 inversions. Likewise, if I swap a random element by 3 positions. I end up creating 3 inversions. Similarly if I swap an element by 4 positions. I end up creating 4 inversions. ...