SnowflakeOA #17
Perfect Pairs
估计中等评测数据准备中,可先阅读题面
A pair of integers (x, y) is perfect if both of the following conditions are met:
min(|x - y|, |y - x|) ≤ min(|x|, |y|)
max(|x - y|, |y - x|) > max(|x|, |y|)
Given an array arr of length n, find the number of perfect pairs
(arr[i], arr[j]) where 0 ≤ i Function Description Complete the function getPerfectPairsCountin the editor below.getPerfectPairsCount` has the following parameter:
int arr[n]: an array of integers Returnsint: the number of perfect pairs
Constraints
- 2 ≤ n ≤ 2*10⁵
- -10⁹ ≤ arr[i] ≤ 10⁹