Code RoomMaximum XOR pair
HardPrep Room Coding #116

Maximum XOR pair

CodingAlgorithms & data structuresSenior–Staff~35 min

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]) → 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