Question
Maximum Signal Interference
A wireless network has
Two devices are said to interfere maximally when the bitwise XOR of their channel identifiers is as large as possible. Find the maximum possible value of
Input
The first line contains a single integer KaTeX can only parse string typed expression — the number of devices.
The second line contains KaTeX can only parse string typed expression integers KaTeX can only parse string typed expression — the channel identifiers.
Output
Print a single integer — the maximum XOR value achievable between any two distinct devices.
Example
Example 1:
Input
KaTeX can only parse string typed expression, which is the maximum XOR achievable among all pairs in this set.
Example 2:
Input
Both devices use the same identifier, so their XOR is KaTeX can only parse string typed expression, which is also the only possible pair.
Example 3:
Input
KaTeX can only parse string typed expression, which is the maximum among all pairs of these powers of two.
Input
6
3 10 5 25 2 8Output28ExplanationKaTeX can only parse string typed expression, which is the maximum XOR achievable among all pairs in this set.
Example 2:
Input
2
0 0Output0ExplanationBoth devices use the same identifier, so their XOR is KaTeX can only parse string typed expression, which is also the only possible pair.
Example 3:
Input
5
1 2 4 8 16Output24ExplanationKaTeX can only parse string typed expression, which is the maximum among all pairs of these powers of two.