Maximum XOR Elimination Score
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Rippling reported this one in July 2026, and the detail that matters is in the example: every elimination sequence builds a spanning tree over the original values. That's the whole problem. It's a maximum spanning tree where edge weight is x XOR y, tagged bit-manipulation. If you've got an OA invite and 48 hours, learn to spot the disguise. The elimination story is theater. StealthCoder sits invisibly as a safety net if you blank on the live OA, but the reduction below is short enough to memorize tonight.
The problem
You are given an integer array nums. Initialize score = 0. While more than one number remains, choose two remaining numbers x and y, add x XOR y to the score, and remove either x or y. The other chosen number remains unchanged. Return the maximum score obtainable when exactly one number remains. Function maximumXorScore(nums: int[]) → long Examples Example 1 nums = [1, 2, 3, 4, 5] return = 25 One optimal sequence scores 2 XOR 5 = 7, 1 XOR 4 = 5, 4 XOR 3 = 7, and 3 XOR 5 = 6, removing the first listed value each time. The total is 25. Every elimination sequence selects a spanning tree on the original values, and no spanning tree has a larger total. Example 2 nums = [1, 2, 4] return = 11 Choose 2 and 4 for a score of 6 and remove 2. Then choose 1 and 4 for 5 more, giving 11. Constraints 1 <= nums.length <= 1000 0 <= nums[i] <= 10^9
Reported by candidates. Source: FastPrep
Pattern and pitfall
Reframe it. Each step picks two remaining numbers, scores their XOR, and deletes one. After n-1 steps you've used n-1 edges, and the edges connect all n values without a cycle. So the answer is the maximum spanning tree on a complete graph where weight(i,j) = nums[i] XOR nums[j]. With n up to 1000, that's about 500k edges, so Prim's in O(n^2) works cleanly with no edge list. Keep a best[] array, pick the unvisited node with the largest key, add it, and update the others. Use a 64-bit sum, since 999 edges near 2^30 overflow 32 bits. The pitfall is trying greedy pairing or a trie-only approach and missing the tree structure. A binary trie with Boruvka is the faster route, but you don't need it at this size. If you freeze mid-OA, StealthCoder is the hedge that gives you the Prim's code fast.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Maximum XOR Elimination Score cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum XOR Elimination Score FAQ
What's the trick in Maximum XOR Elimination Score?+
Every elimination sequence forms a spanning tree over the original numbers. So the task is a maximum spanning tree where each edge weighs a XOR b. Once you see that, it's standard Prim's or Kruskal's, not a bit puzzle.
Is O(n^2) fast enough for n = 1000?+
Yes. Dense Prim's does about a million XOR comparisons at n = 1000, which is trivial. You don't need to build the edge list. Compute XORs on the fly while updating the best-key array for each unvisited node.
Why does the return type say long?+
You're summing up to 999 XOR values, each as large as roughly 2^30. That total can pass the 32-bit integer limit. Use a 64-bit accumulator in your language, or the sum will overflow and fail large tests.
What edge cases should I test before submitting?+
Test n = 1, where no steps happen and the score is 0. Test n = 2, where the answer is just a XOR b. Test duplicates and zeros, since equal values give XOR 0 and shouldn't break your Prim's initialization.
How do I prepare for this in 48 hours?+
Practice maximum spanning tree with Prim's on a dense graph and write it from memory once. Then skim the binary trie plus Boruvka idea for XOR spanning trees. Rippling's July 2026 report suggests the reduction is the hard part, not the code.