Class Solution
java.lang.Object
g2401_2500.s2425_bitwise_xor_of_all_pairings.Solution
2425 - Bitwise XOR of All Pairings.<p>Medium</p>
<p>You are given two <strong>0-indexed</strong> arrays, <code>nums1</code> and <code>nums2</code>, consisting of non-negative integers. There exists another array, <code>nums3</code>, which contains the bitwise XOR of <strong>all pairings</strong> of integers between <code>nums1</code> and <code>nums2</code> (every integer in <code>nums1</code> is paired with every integer in <code>nums2</code> <strong>exactly once</strong> ).</p>
<p>Return <em>the <strong>bitwise XOR</strong> of all integers in</em> <code>nums3</code>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums1 = [2,1,3], nums2 = [10,2,5,0]</p>
<p><strong>Output:</strong> 13</p>
<p><strong>Explanation:</strong></p>
<p>A possible nums3 array is [8,0,7,2,11,3,4,1,9,1,6,3].</p>
<p>The bitwise XOR of all these numbers is 13, so we return 13.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums1 = [1,2], nums2 = [3,4]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong></p>
<p>All possible pairs of bitwise XORs are nums1[0] ^ nums2[0], nums1[0] ^ nums2[1], nums1[1] ^ nums2[0], and nums1[1] ^ nums2[1].</p>
<p>Thus, one possible nums3 array is [2,5,1,6]. 2 ^ 5 ^ 1 ^ 6 = 0, so we return 0.</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= nums1.length, nums2.length <= 10<sup>5</sup></code></li>
<li><code>0 <= nums1[i], nums2[j] <= 10<sup>9</sup></code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
xorAllNums
public int xorAllNums(int[] nums1, int[] nums2)
-