reverse-pairs.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:lc-all-solutions 作者: csujedihy 项目源码 文件源码
def reversePairs(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        n = len(nums)
        ans = 0
        bst = []
        for num in nums:
            right = 2 * num
            idx = bisect.bisect_right(bst, right)
            ans += len(bst) - idx
            bisect.insort(bst, num)
        return ans
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号