mergeSort
that takes the array nums
and the indices left
and right
as arguments.left
is greater than or equal to right
, return 0 as there are no reverse pairs to count.mid
as (left + right) / 2
.mergeSort
on the left subarray (left
to mid
) and the right subarray (mid + 1
to right
) and sum their returned reverse pair counts.i
to left
and j
to mid + 1
.