Search
⌘K

Leetcode 3215. Count Triplets with Even XOR Set Bits II

Given an integer array, count the number of index triplets whose bitwise XOR has an even number of 1-bits. Key insight: parity of popcount is preserved under XOR, so you can reduce the problem to counting triplets by popcount parity (all three even, or exactly two odd + one even) and compute counts combinatorially for O(n) time.


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.