Ctrl K

Even-Bit XOR Triples

Easy
You get three lists of non-negative integers: first, second and third. A triple picks one element from each list: first[i], second[j], third[k]. For a triple, take the bitwise XOR of its three numbers and count the ones in its binary form. The triple is good if that count is even (zero is even). Return the number of good triples. Triples with different indices are counted separately even if they hold the same numbers.
Example 1
first=[4], second=[7], third=[1] → 0

The only triple gives 4 XOR 7 XOR 1 = 2, which is 10 in binary: one set bit, an odd count. The answer is 0.

Example 2
first=[0, 3], second=[5], third=[6, 1] → 2

0^5^6 = 3 (11, two set bits) counts; 0^5^1 = 4 (100) does not; 3^5^6 = 0 (zero set bits) counts; 3^5^1 = 7 (111) does not. The answer is 2.

Example 3
first=[1, 2], second=[3, 3], third=[0] → 0
Constraints
  • 1 ≤ len(first), len(second), len(third) ≤ 100
  • 0 ≤ first[i], second[j], third[k] ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Unpaired Value EasyThe Lost Ticket EasyDoubled Tag, Lost Tag EasyMirror and Negate a Bitmap EasyMultiple of Five at Every Step Easy
loading Python…
Input
first=[4], second=[7], third=[1]
Expected
0

Run checks the first 3 tests in your browser. Submit checks all 55 tests on the server, hidden ones included.