first and second.
For every pair (i, j), where i indexes first and j indexes second, compute first[i] AND second[j] (bitwise AND). That gives len(first) · len(second) numbers.
Return the bitwise XOR of all of them.
With lengths up to 10⁵, going through every pair is too slow, so look for a faster way.first=[5, 3], second=[6] → 6
5 AND 6 = 4 and 3 AND 6 = 2, and 4 XOR 2 = 6.
first=[7], second=[1, 2, 4] → 7
The pairs give 1, 2 and 4; 1 XOR 2 XOR 4 = 7.
first=[8, 8], second=[15] → 0
Both pairs give 8, and 8 XOR 8 = 0.
first=[5, 3], second=[6]
6
Run checks the first 3 tests in your browser. Submit checks all 98 tests on the server, hidden ones included.