Back to course home
0% completed
Vote For New Content
Solution: Reverse Pairs
Problem Statement
Given an array of integers nums, return the count of reverse pairs in the array.
A reverse pairis a pair (i, j) where:
0 <= i < j < nums.lengthandnums[i] > 2 * nums[j].
Examples
-
Example 1:
- Input:
nums = [4, 3, 4, 1] - Expected Output:
3 - Justification: The three reverse pairs are
(0, 3),(1, 3)and(2, 3).
- Input:
-
Example 2:
- Input:
nums = [4, 1, 2] - Expected Output:
1 - Justification: There is only one reverse pair
(0, 1)since4 > 2 * 1.
- Input:
-
Example 3:
- Input:
.....
.....
.....
Like the course? Get enrolled and start learning!