Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.
Example 1
Input: nums = [3,10,5,25,2,8]
Output: 28
Explanation: In binary, 5 = 00101 and 25 = 11001. XOR sets every bit where they differ, giving 11100 = 28. No other pair does better.
Example 2
Input: nums = [14,70,53,83,49,91,36,80,92,51,66,70]
Output: 127
Explanation: 91 = 1011011 and 36 = 0100100 are exact bit-complements over 7 bits, so their XOR is 1111111 = 127, the largest possible 7-bit value.
Example 3
Input: nums = [0]
Output: 0
Explanation: With one element, the only pair is 0 XOR 0 = 0.
Build the answer from the most significant bit down. At each bit, optimistically assume we can set it, then check whether two number-prefixes actually XOR to the target so far.
Run checks all cases above. Submit evaluates all test cases.