hardTriesAI-applied~35 min
Maximum XOR Between Two Hashed Vectors
Each item is reduced to an integer hash (a compact embedding fingerprint). To find the most dissimilar pair under a Hamming-style metric, compute the maximum XOR achievable between any two hashes.
Problem
Given an integer array nums, return the maximum value of nums[i] XOR nums[j] over all pairs i, j.
Input
An integer array nums.
Output
An integer: the maximum pairwise XOR.
Constraints
- 1 <= nums.length <= 200000
- 0 <= nums[i] <= 2^31 - 1
Examples
Example 1
Input
nums = [3,10,5,25,2,8]
Output
28
5 XOR 25 = 28 is the maximum.
Example 2
Input
nums = [14,70,53,83,49,91,36,80,92,51,66,70]
Output
127
The best pair yields 127.