left and right, both of length n. Split their elements into n pairs so that every pair takes exactly one element from left and exactly one from right. A pair costs the bitwise XOR of its two numbers, and the cost of the whole split is the sum over all pairs.
Return the smallest possible cost.left=[5, 8], right=[9, 4] → 2
Pairing 5↔4 and 8↔9 costs 1 + 1 = 2; pairing 5↔9 and 8↔4 would cost 12 + 12 = 24.
left=[7, 0, 3], right=[3, 6, 1] → 2
The best choice is 7↔6, 0↔1, 3↔3, for a total of 1 + 1 + 0 = 2.
left=[12], right=[12] → 0
len(left) = len(right) = nleft[i], right[i] ≤ 10⁷left=[5, 8], right=[9, 4]
2
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.