Reverse Pairs

Given an integer array, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].

Constraints

  • 1 <= nums.length <= 5 * 10^4
  • -2^31 <= nums[i] <= 2^31 - 1
Saving… · 2 lines
class Solution:
def reversePairs(self, nums: List[int]) -> int:
Console

Click Run to execute sample tests.