Class Solution
-
- All Implemented Interfaces:
public final class Solution2425 - Bitwise XOR of All Pairings.
Medium
You are given two 0-indexed arrays,
nums1andnums2, consisting of non-negative integers. There exists another array,nums3, which contains the bitwise XOR of all pairings of integers betweennums1andnums2(every integer innums1is paired with every integer innums2exactly once ).Return the bitwise XOR of all integers in
nums3.Example 1:
Input: nums1 = 2,1,3, nums2 = 10,2,5,0
Output: 13
Explanation:
A possible nums3 array is 8,0,7,2,11,3,4,1,9,1,6,3.
The bitwise XOR of all these numbers is 13, so we return 13.
Example 2:
Input: nums1 = 1,2, nums2 = 3,4
Output: 0
Explanation:
All possible pairs of bitwise XORs are nums10 ^ nums20, nums10 ^ nums21, nums11 ^ nums20, and nums11 ^ nums21.
Thus, one possible nums3 array is 2,5,1,6. 2 ^ 5 ^ 1 ^ 6 = 0, so we return 0.
Constraints:
<code>1 <= nums1.length, nums2.length <= 10<sup>5</sup></code>
<code>0 <= nums1i, nums2j<= 10<sup>9</sup></code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegerxorAllNums(IntArray nums1, IntArray nums2)-
-
Method Detail
-
xorAllNums
final Integer xorAllNums(IntArray nums1, IntArray nums2)
-
-
-
-