Given an integer array nums, count the number of reverse pairs: indices (i,j) where i<j and nums[i]>2⋅nums[j]. Example: nums =[1,3,2,3,1] returns 2.
Reverse pairs: (1,4) since 3>2⋅1, and (3,4) since 3>2⋅1.
This is similar to inversions, but the condition is a[i]>2⋅a[j] instead of a[i]>a[j]. Approach: process right to left, query for elements less than a[i]/2. Constraints: up to 5⋅104 elements, values up to 231−1.