Description
Given an integer array nums, return the maximum XOR of two numbers in the array. Use a trie for O(n) solution.
Examples
Input:
nums = [3,10,5,25,2,8]Output:
28Explanation:
Maximum XOR is 5 ^ 25 = 28.
Input:
nums = [1]Output:
1Explanation:
Edge case with a single-element array.
Input:
nums = [14, 70, 53, 83, 49, 91, 36, 80, 92, 51, 66, 70]Output:
127Explanation:
The maximum XOR is 127, achieved by 36 ^ 91.
Constraints
- •
1 ≤ nums.length ≤ 2 * 10⁵ - •
0 ≤ nums[i] ≤ 2³¹ - 1