Search
⌘K

Leetcode 3649. Number of Perfect Pairs

Count the number of index pairs (i<j) for which the absolute sum/difference of the pair satisfies both min(|a−b|,|a+b|) ≤ min(|a|,|b|) and max(|a−b|,|a+b|) ≥ max(|a|,|b|). The challenge is to algebraically characterize these absolute-value conditions so you can count qualifying pairs efficiently (n up to 1e5) rather than testing all O(n^2) pairs.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.