class Solution:
def reversePairs(self, nums: List[int]) -> int:
def helper_merge_sort(nums):
if len(nums) <=1:
return nums, 0
res = []
N = len(nums)
l, lc = helper_merge_sort(nums[:N//2])
r, rc = helper_merge_sort(nums[N//2:])
i, j, ans = 0, 0, lc + rc
while i < len(l) and j < len(r):
if nums[i] > 2 * nums[j]:
res.append(nums[j])
j += 1
ans += j
else:
if nums[i] <= nums[j]:
res.append(nums[i])
i += 1
else:
res.append(nums[j])
j += 1
while i < len(l):
res.append(nums[i])
ans += j
i += 1
while j < len(r):
res.append(nums[j])
j += 1
return res, ans
return helper_merge_sort(nums)[1]
line 12, 我只在满足nums[i] > 2 * nums[j] 这个条件的时候 ans += j,其他时候正常merge,我不知道我逻辑上错在哪里了。