Find minimum XOR values in a given array
The program is running in quadratic time. As usual, to improve performance you need to change the algorithm.

Sort the numbers into 32 buckets, according to where the most significant bit of the number is. Convince yourself that if a bucket contains more than one number, it makes no sense to test them against the numbers from other buckets (the result is guaranteed to not be minimal). A cross-bucket xor should be tested only if two adjacent buckets contain just one number each.

Work recursively with each bucket.