Loading...
Loading...
Loading...
Given n non-negative integers, print the largest value of a XOR b over all pairs of two different positions. XOR compares two numbers bit by bit and gives a 1 where the bits differ. The two numbers may be equal.
Example 1
Input
6 3 10 5 25 2 8
Output
28
5 XOR 25 gives 28.
Example 2
Input
2 7 7
Output
0
Try the problem first. Open one hint at a time.
Store every number as a path of 30 bits in a trie, high bit first.
For each number, walk the trie and prefer the child with the opposite bit at every step.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor