Maximum XOR pair
Given a list of non-negative integers `nums`, return the maximum value of `nums[i] XOR nums[j]` over all pairs i != j. If fewer than two elements are present, return 0. Aim for linear-in-bits time rather than the O(n^2) pairwise scan. `0 <= len(nums) <= 200000`, `0 <= nums[i] < 2^31`.
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