values. Choose two elements (the same element may be chosen twice) so that their bitwise XOR is as large as possible, and return that XOR.
Trying every pair takes O(n²); aim for something faster.values=[6, 9, 4, 12] → 15
6 = 0110 and 9 = 1001 differ in all four bits: 6 XOR 9 = 15.
values=[7, 7] → 0
Both numbers are equal, so their XOR is 0.
values=[16, 3, 20, 2] → 23
The best is 3 XOR 20 = 23; for comparison, 2 XOR 20 = 22 and 16 XOR 3 = 19.
values=[6, 9, 4, 12]
15
Run checks the first 3 tests in your browser. Submit checks all 99 tests on the server, hidden ones included.