Tap here to switch tabs
Problem
Submissions

Problem: Minimum XOR Sum of Two Arrays

med
30 min
Try to solve the Minimum XOR Sum of Two Arrays problem.

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

med
30 min
Try to solve the Minimum XOR Sum of Two Arrays problem.

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