Question

Write a function that takes an array and returns the count of reverse pairs (i, j) where i < j and arr[i] > 2 * arr[j]?

Login to Submit

Examples

Input: [16, 20, 13, 21, 22, 29, 10, 3, 29, 18]
Output: 10

Input: [28, 14, 8, 27, 18, 27, 28, 13]
Output: 5

Input: [8, 17, 20, 3]
Output: 3