Back to problems

Sum of XOR Values Over All Array Pairs

Algorithm · IBM · Medium

Pairwise XOR Summation Medium You are given two arrays of non‑negative integers, A and B, of sizes n and m respectively. For every element a in A and every element b in B, compute the bitwise XOR a ⊕ b. Return the sum of all these XOR results: \[ \displaystyle \sum_{a \in A} \sum_{b \in B} (a \oplus b) \] Input The first line contains two space‑separated integers n and m. The second line contains n space‑separated integers representing the elements of A. The third line…

Checking your access…