Tap here to switch tabs
Problem
Submissions

Problem: Minimum XOR Sum of Two Arrays

Minimum XOR Sum of Two Arrays pairs elements from two equal-length integer arrays after rearranging the second, then returns the smallest possible total of their pairwise XOR values.

Statement

You are given two integer arrays nums1 and nums2, each of length n.

The XOR sum of the two arrays is defined as:

(nums1[00] ⊕\oplus nums2[00]) ++ (nums1[11] ⊕\oplus nums2[11]) ++ …\dots ++ (nums1[n −- 11] ⊕\oplus nums2[n −- 11])

where ⊕\oplus represents the bitwise XOR operation.

Rearrange the elements of nums2 such that the resulting XOR sum is minimized.

Return the minimum XOR sum achievable after rearranging nums2.

Constraints:

  • n ==== nums1.length

  • n ==== nums2.length

  • 1≤1 \leq n ≤14\leq 14

  • 0≤0 \leq nums1[i], nums2[i] ≤107\leq 10^7

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum XOR Sum of Two Arrays

Minimum XOR Sum of Two Arrays pairs elements from two equal-length integer arrays after rearranging the second, then returns the smallest possible total of their pairwise XOR values.

Statement

You are given two integer arrays nums1 and nums2, each of length n.

The XOR sum of the two arrays is defined as:

(nums1[00] ⊕\oplus nums2[00]) ++ (nums1[11] ⊕\oplus nums2[11]) ++ …\dots ++ (nums1[n −- 11] ⊕\oplus nums2[n −- 11])

where ⊕\oplus represents the bitwise XOR operation.

Rearrange the elements of nums2 such that the resulting XOR sum is minimized.

Return the minimum XOR sum achievable after rearranging nums2.

Constraints:

  • n ==== nums1.length

  • n ==== nums2.length

  • 1≤1 \leq n ≤14\leq 14

  • 0≤0 \leq nums1[i], nums2[i] ≤107\leq 10^7