Company: Cohesity
Difficulty: medium
Buy One Get One Free A campus electronics store is designing a promotion: for two distinct items priced a and b, item b can be handed over free with item a whenever a costs more than twice as much as b. Given the price list of all N items the store stocks, work out how many distinct (a, b) pairs qualify for this giveaway. Input Format Input consists of a single array of integers giving each product's price. Type: array.integer arr Output Format Return one integer: the total number of qualifying pairs. Type: integer64 Example Input: arr: [2,4,3,5,1] Output: 3 Explanation: Checking every combination against the price array, three pairs clear the more-than-double bar: arr[1] = 4 paired with arr[4] = 1, since 4 exceeds 2 * 1 arr[2] = 3 paired with arr[4] = 1, since 3 exceeds 2 * 1 arr[3] = 5 paired with arr[4] = 1, since 5 exceeds 2 * 1 Constraints 1 <= arr.length <= 50000 Each element in arr is an integer Execution Limits Time Limit: 0.5 seconds (cpp) Memory Limit: 1 GB C++ Syntax T