#421
Maximum XOR of Two Numbers in an Array
specialist · 820 · lc medium +31 · verified · 53.4% accepted · 5,920 likes · top 44%
Description
Given an integer array nums, find the largest possible result of XOR-ing any two elements nums[i] and nums[j] (where 0 <= i <= j < n). Return that maximum XOR value.
Example 1:
Input: nums = [3,10,5,25,2,8]
Output: 28
Explanation: The maximum result is 5 XOR 25 = 28.
Example 2:
Input: nums = [14,70,53,83,49,91,36,80,92,51,66,70]
Output: 127
Code
1
2
3