bugfree Icon
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course
interview-course

Leetcode Problem 421. Maximum XOR of Two Numbers in an Array

421. Maximum XOR of Two Numbers in an Array

Leetcode Solutions

Bitwise Trie Approach for Maximum XOR

  1. Initialize an empty trie.
  2. For each number in the input array, convert it to binary and insert it into the trie.
  3. For each number, traverse the trie to find the maximum XOR value with the numbers already in the trie.
  4. Update the maximum XOR value if the current XOR is greater.
  5. Return the maximum XOR value after processing all numbers.
UML Thumbnail

Bitwise Prefixes in HashSet Approach for Maximum XOR

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...