Search
⌘K

Leetcode 2857. Count Pairs of Points With Distance k

Count unordered pairs of points (i<j) whose distance defined as (xi XOR xj) + (yi XOR yj) equals k; with n up to 50k and k ≤ 100, the challenge is to avoid O(n^2) by using frequency maps and combining counts of possible XOR contributions (0..k) for x and y.


Question Timeline

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

Comments

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