Search
⌘K

Leetcode 2354. Number of Excellent Pairs

Count ordered pairs (a, b) from values in nums whose bit-counts satisfy popcount(a)+popcount(b) >= k. Key insight: popcount(a|b)+popcount(a&b)=popcount(a)+popcount(b), so deduplicate values, tally frequencies of popcounts (0–30), and count pairs of counts whose sum ≥ k.


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.