MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / reversePairs

Method reversePairs

DP/ReversePairs.py:44–58  ·  view source on GitHub ↗

:type nums: List[int] :rtype: int

(self, nums)

Source from the content-addressed store, hash-verified

42
43class Solution(object):
44 def reversePairs(self, nums):
45 """
46 :type nums: List[int]
47 :rtype: int
48 """
49 _base = []
50
51 result = 0
52
53 for i in range(len(nums)-1,-1,-1):
54 index = bisect.bisect_left(_base, nums[i])
55 result += index
56 bisect.insort_right(_base, nums[i]*2)
57
58 return result
59

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected