Maximum XOR pair
Given a list of non-negative integers (length 2 to 2e5, each value 0 <= x < 2^31), return the maximum value of nums[i] XOR nums[j] over all pairs i != j. An O(n * bits) bitwise-trie solution is expected; the O(n^2) brute force is too slow for large inputs.
Implement
max_xor_pair(nums: list[int]) → intExamples
in
[[3,10,5,25,2,8]]out28What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 35 min
solution.py
InputExpectedGot
[[3,10,5,25,2,8]]28not run yetsample