Input: arr[]= {2, 1, 3}, K = 3
Output: 12
Explanation:
Appending 2 copies of array arr[] modifies arr[] to {2, 1, 3, 2, 1, 3, 2, 1, 3}
The pairs (arr[i], arr[j]), where i < j and arr[i] > arr[j] are (2, 1), (2, 1), (2, 1), (3, 2), (3, 1), (3, 2), (3, 1), (2, 1), (2, 1), (3, 2), (3, 1), (2, 1)
Therefore, the total number of inversions are 12.
Input: arr[]= {6, 2}, K = 2
Output: 3
Explanation:
Appending 2 copies of array arr[] = {6, 2, 6, 2}
The pairs (arr[i], arr[j]), where i < j and arr[i] > arr[j] are (6, 2), (6, 2), (6, 2)
Therefore, the total number of inversions are 3.