Bird
Raised Fist0

Consider the following Python code snippet implementing maximum XOR using a trie. What is the output of maxXOR([5, 25])?

easy🧾 Trace Q3 of Q15
Bit Manipulation - Maximum XOR of Two Numbers
Consider the following Python code snippet implementing maximum XOR using a trie. What is the output of maxXOR([5, 25])?
def maxXOR(nums):
    # Implementation uses a binary trie
    # ... (code omitted for brevity)
    pass
A15
B30
C20
D28
Step-by-Step Solution
Solution:
  1. Step 1: Calculate XOR of pairs

    5 XOR 25 = 28, 5 XOR 5 = 0, 25 XOR 25 = 0.
  2. Step 2: Identify maximum XOR

    The maximum XOR among pairs is 28.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    5 ^ 25 = 28 [OK]
Quick Trick: XOR pairs and pick max [OK]
Common Mistakes:
MISTAKES
  • Confusing XOR with addition or subtraction
  • Calculating XOR with wrong pairs
  • Assuming maximum XOR is always the max number
Trap Explanation:
PITFALL
  • Incorrectly computing XOR or mixing up pairs leads to wrong answers.
Interviewer Note:
CONTEXT
  • Tests ability to trace XOR computations and understand output.
Master "Maximum XOR of Two Numbers" in Bit Manipulation

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bit Manipulation Quizzes