Problem · Array
Maximum XOR Elimination Score
Learn this problemProblem statement
You are given an integer array nums. Initialize score = 0.
While more than one number remains:
- Choose two remaining numbers
xandy. - Add
x XOR ytoscore. - Remove either
xory; the other chosen number remains unchanged.
Return the maximum score obtainable when exactly one number remains.
Function
maximumXorScore(nums: int[]) → longExamples
Example 1
nums = [1, 2, 3, 4, 5]return = 30An optimal sequence accumulates a total XOR score of 30.
Example 2
nums = [1, 2, 4]return = 11Choose 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 <= 10000 <= nums[i] <= 10^9
More Rippling problems
- Delivery Cost TrackerPHONE SCREEN · Seen Jul 2026
- Corporate Card Expense RulesPHONE SCREEN · Seen Jun 2026
- Camel CardsPHONE SCREEN · Seen May 2026
- Article Vote TrackerPHONE SCREEN · Seen May 2026
- Employee Resource Access ManagementONSITE INTERVIEW · Seen Jan 2026
- Limit an Organization Tree's HeightONSITE INTERVIEW · Seen Aug 2025
- Distributed System RecoveryOA · Seen Jul 2025
- Server Upgrade PlanningOA · Seen Jul 2025