DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Trie

Maximum XOR of Two Numbers in Array

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Maximum XOR of Two Numbers in Array** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Bit trie; for each number find complement greedily **Edge Cases to Consider:** - (1) Array with one element - (2) All same numbers (XOR=0) - (3) 32-bit overflow

Examples

Example 1
Input: [3,10,5,25,2,8]
Output: 28
Explanation: 5 XOR 25 = 28
Example 2
Input: [0]
Output: 0
Explanation: Single element
Example 3
Input: [2,4]
Output: 6
Explanation: 2 XOR 4 = 6

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Array with one element
  • ▪All same numbers (XOR=0)
  • ▪32-bit overflow
Frequently Asked At
AmazonGoogleAdobeMeta