This question was asked in Scalar Discovery challenge which is over now. The question is-

Given two arrays A and B of size N. We are allowed to shuffle the array A, such that the sum of “A[i] xor B[i]” is minimized. Output the minimised sum.

Example-

3

1 0 3

5 3 4

Ans- 8

Constraints-

1<=N<=16

0<=A[i],B[i]<=10^8

What should be the approach for this?