Problem statement

https://leetcode.com/problems/find-xor-sum-of-all-pairs-bitwise-and/

Solution

We can use distribution property of XOR with rescepct to AND and writ is as the following oneliner.

Complexity

Time and space complexity is O(n).

Code

class Solution:
    def getXORSum(self, A, B):
        return reduce(xor, A) & reduce(xor, B)