Given an integer array, count the number of inversions — pairs (i,j) with i<j and nums[i]>nums[j]. Use a merge-sort based approach for O(n log n).
Input: An integer array.
Output: Integer — inversion count.
Input: [2,4,1,3,5]
Output: 3
Explanation: Inversions: (2,1),(4,1),(4,3).Input: [1,2,3]
Output: 0
Explanation: Already sorted.Input: [3,2,1]
Output: 3
Explanation: All pairs inverted.0<=n<=10^5-10^9<=nums[i]<=10^9