Skip to content

Practice Maximum XOR of Two Numbers in an Array

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#421
LeetCode Problem

Maximum XOR of Two Numbers in an Array

Problem Statement

Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.

Source: Maximum XOR of Two Numbers in an Array on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [3,10,5,25,2,8]
Output
28

# Example 2

Input
nums = [14,70,53,83,49,91,36,80,92,51,66,70]
Output
127

Constraints

1 <= nums.length <= 2 * 10^5
0 <= nums[i] <= 2^31 - 1

Related LeetCode Problems

Practice more problems similar to Maximum XOR of Two Numbers in an Array.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.