Bitwise XOR of All Pairings

You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers.

Let there be another array, nums3, which contains the bitwise XOR of all pairings of integers between nums1 and nums2; every integer in nums1 is paired with every integer in nums2 exactly once.

Return the bitwise XOR of all integers in nums3.

Example 1
Inputnums1 = [2,1,3], nums2 = [10,2,5,0]
Output13
A possible nums3 array is [8, 0, 7, 2, 11, 3, 4, 1, 9, 1, 6, 3], and the bitwise XOR of all these numbers is 13.
Example 2
Inputnums1 = [1,2], nums2 = [3,4]
Output0
One possible nums3 array is [2, 5, 1, 6], and 2 ^ 5 ^ 1 ^ 6 = 0.

Constraints

  • 1 <= nums1.length, nums2.length <= 10^5
  • 0 <= nums1[i], nums2[j] <= 10^9

Asked at 3 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate