Skip to content

Practice Maximum Strong Pair XOR II

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

Hard#2935
LeetCode Problem

Maximum Strong Pair XOR II

Problem Statement

Choose two values x and y from nums satisfying abs(x - y) <= min(x,y). You may choose the same entry twice. Return the largest possible bitwise XOR of a valid pair.

Source: Maximum Strong Pair XOR II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,2,3,4,5]
Output
7

# Example 2

Input
nums = [10,100]
Output
0

# Example 3

Input
nums = [500,520,2500,3000]
Output
1020

Constraints

1 <= nums.length <= 5 * 10^4
1 <= nums[i] <= 2^20 - 1

Related LeetCode Problems

Practice more problems similar to Maximum Strong Pair XOR II.

Review your practice with PhantomCodeAI

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