Given two arrays nums1 and nums2 of length , rearrange nums2 to find the smallest XOR sum: where is a permutation. Example: nums1 , nums2 . If we pair with and with : .
This is minimum. This is the assignment problem: match each element of nums1 to a unique element of nums2. The bitmask tracks which elements of nums2 have been used.