#3649
Number of Perfect Pairs
expert · 1090 · lc medium +32 · 33.5% accepted · 95 likes · top 11%
Description
Given an integer array nums, a pair (i, j) with i < j is perfect when, letting a = nums[i] and b = nums[j]: min(|a-b|, |a+b|) <= min(|a|, |b|) and max(|a-b|, |a+b|) >= max(|a|, |b|). Count and return the number of distinct perfect pairs.
Code
1
2
3