~/algor $ cat problems/bit-eng-katta-xor
Pair with the largest XOR
Medium
1000 ms
128 MB
60%
$n$ integers $a_{1}, a_{2}, \ldots, a_{n}$ are given. Choose two numbers at different positions ($i \ne j$) so that $a_{i} \oplus a_{j}$ is as large as possible. Find this largest value. Here $\oplus$ is the bitwise XOR operation.
Input
The first line contains a positive integer $n$. The second line contains $n$ integers $a_{i}$ separated by spaces.
Output
One integer — the largest $a_{i} \oplus a_{j}$.
Note
$2 \le n \le 10^{5}$
$0 \le a_{i} \lt 2^{30}$
Examples
Input #1
6 3 10 5 25 2 8
Output #1
28
Input #2
2 7 7
Output #2
0