Title
from typing import List
class Solution:
def countInversions(self, nums: List[int]) -> int:
invCount = 0
for i in range(len(nums)-1):
for j in range(i+1, len(nums)-1):
if nums[i] > nums[j]:
print("({},{})".format(nums[i], nums[j]))
invCount += 1
return invCount
sol = Solution()
sol.countInversions([2, 5, 1, 7, 9])
def mergeSort(arr):
mid = len(arr)//2
leftArr = arr[:mid]
rightArr = arr[mid:]
mergeSort(leftArr)
mergeSort(rightArr)