Gamified challenge · Binary trie
A miner's pouch holds crystals with non-negative charges nums[i] (each below 2^31). Fusing two different crystals releases nums[i] XOR nums[j] energy (two crystals may carry the same charge).
Write maxXor(nums) (Python: max_xor(nums)) that returns the largest energy any pair can release. With fewer than two crystals, return 0.
Example: for [6, 13, 9, 4, 1], 13 XOR 1 = 1101 XOR 0001 = 1100 = 12, but 6 XOR 9 = 0110 XOR 1001 = 1111 = 15 is the biggest blast, so the answer is 15.
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google