class Solution(object):
def findMaximumXOR(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max,mask=0,0
for i in range(31,-1,-1):
mask|=(1<<i)
prefix_set=set()
for num in nums:
prefix_set.add(num&mask)
temp=max|(1<<i)
for prefix in prefix_set:
if temp^prefix in prefix_set:
max=temp
break
return max
class Solution(object):
def findMaximumXOR(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
answer=0
for i in range(31,-1,-1):
answer<<=1
prefixes={num>>i for num in nums}
answer+=any(answer^1^prefix in prefixes for prefix in prefixes)
return answer