Maximum XOR of Two Numbers in Array Problem
Maximum XOR of Two Numbers in Array Problem — ExecCode Medium DSA Practice
Solve the Maximum XOR of Two Numbers in Array problem on ExecCode. Free online medium DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n, by greedily building the answer one bit at a time from the most significant bit.
Examples
Input nums = [3, 10, 5, 25, 2, 8]; Output 28. Input nums = [14, 70, 53, 83, 49, 91, 36, 80, 92, 51, 66, 70]; Output 127. Input nums = [0]; Output 0
Constraints
1 <= nums.length <= 200000 0 <= nums[i] <= 2^31 - 1
Practice Maximum XOR of Two Numbers in Array free on ExecCode. Browse DSA problems, topic map, and placement guides.