values. Call two numbers x and y *close* when |x − y| ≤ min(x, y), meaning the larger one is at most twice the smaller.
Pick two close numbers from the array so that their bitwise XOR is as large as possible, and return that value. The same element may be used twice.values=[3, 5, 6, 12] → 10
The close pairs are (3, 5), (3, 6), (5, 6), (6, 12) and every number with itself. The largest XOR is 6 XOR 12 = 10.
values=[4, 20] → 0
20 − 4 = 16 is more than 4, so 4 and 20 are not close. Only pairs of a number with itself remain, and their XOR is 0.
values=[7, 8, 9, 15] → 15
values=[3, 5, 6, 12]
10
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.