Code Room
CodingHard
Question
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.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.