Python | Leetcode Python题解之第493题翻转对
题目:
题解:
from sortedcontainers import SortedList
class Solution:def reversePairs(self, nums: List[int]) -> int:st=SortedList()n,ans=len(nums),0for i in range(n):ans+=i-bisect_right(st,nums[i]*2)st.add(nums[i])return ans