256. Reverse Pairs
HardSorting
Given an integer array nums, 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].
Examples
Input: [1,3,2,3,1]
Output: 2
Explanation: Reverse pairs: (3,1) at indices (1,4) and (3,4).
Constraints
- 1 <= nums.length <= 5 * 10^4
- -2^31 <= nums[i] <= 2^31 - 1
Loading...
Run checks all cases above. Submit evaluates all test cases.