Given an integer array nums, return the number of inversions in the array, where an inversion is a pair (i, j) such that i < j and nums[i] > nums[j]. This is a standard Fenwick Tree application after coordinate compression.
nums = integer array
total number of inversions
Example 1:
Input:
nums = [8,4,2,1]
Output:
6
Explanation:
Every earlier element is larger than every later element, so all 6 pairs are inversions.
Example 2:
Input:
nums = [3,1,2]
Output:
2
Explanation:
The inversions are (3,1) and (3,2).