421. Maximum XOR of Two Numbers in an Array

Given anon-emptyarray of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai< 231.

Find the maximum result of aiXOR aj, where 0 ≤i,j<n.

Could you do this in O(n) runtime?

Example:

Input:[3, 10, 5, 25, 2, 8]Output:28Explanation:The maximum result is5^25= 28.

利用字典树,


421. Maximum XOR of Two Numbers in an Array_第1张图片

你可能感兴趣的:(421. Maximum XOR of Two Numbers in an Array)