421. Maximum XOR of Two Numbers

2016-12-19  本文已影响0人  我是你的果果呀

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.

利用字典树,

上一篇 下一篇

猜你喜欢

热点阅读