mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-06 16:01:41 +08:00
update
This commit is contained in:
34
leetcode/problem/bitwise-xor-of-all-pairings.html
Normal file
34
leetcode/problem/bitwise-xor-of-all-pairings.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<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> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums1 = [2,1,3], nums2 = [10,2,5,0]
|
||||
<strong>Output:</strong> 13
|
||||
<strong>Explanation:</strong>
|
||||
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.
|
||||
</pre>
|
||||
|
||||
<p><strong>Example 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> nums1 = [1,2], nums2 = [3,4]
|
||||
<strong>Output:</strong> 0
|
||||
<strong>Explanation:</strong>
|
||||
All possible pairs of bitwise XORs are nums1[0] ^ nums2[0], nums1[0] ^ nums2[1], nums1[1] ^ nums2[0],
|
||||
and nums1[1] ^ nums2[1].
|
||||
Thus, one possible nums3 array is [2,5,1,6].
|
||||
2 ^ 5 ^ 1 ^ 6 = 0, so we return 0.
|
||||
</pre>
|
||||
|
||||
<p> </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>
|
Reference in New Issue
Block a user