Code RoomMaximum XOR pair
HardPrep Room Coding #973

Maximum XOR pair

CodingAlgorithms & data structuresSenior–Staff~35 min

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]) → int
Examples
in[[3,10,5,25,2,8]]out28
What 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
InputExpectedGot
[[3,10,5,25,2,8]]28not run yetsample