1394. Find XOR Sum of All Pairs Bitwise AND

HardBit ManipulationBit MathXORDistributive Law

Given two arrays arr1 and arr2, form the bitwise AND of every pair (arr1[i], arr2[j]) and return the XOR of all these AND values.

Input: A JSON object {"arr1": [<non-negative integers>], "arr2": [<non-negative integers>]}.

Output: Return the XOR of arr1[i] AND arr2[j] over all pairs.

Examples

Example 1
Input: {"arr1":[1,2,3],"arr2":[6,5]}
Output: 0
Explanation: The XOR of all pairwise ANDs is 0.
Example 2
Input: {"arr1":[12],"arr2":[4]}
Output: 4
Explanation: 12 AND 4 = 4.

Constraints

Asked by

AmazonGoogleMicrosoftMetaAdobe
Solve this problem in the editor →