Maximum XOR Elimination Score
Updated
Problem statement
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[]) → longExamples
Example 1
nums = [1, 2, 3, 4, 5]return = 25One 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 = 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 Online Assessment questions
- Most Segments That Sort the ArrayOA · Seen Nov 2026
- Palindromic Paths to the RootOA · Seen Nov 2026
- Server InvestmentOA · Seen Nov 2026
- Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- REST API: Highest International StudentsOA · Seen Sep 2026
- Token ValidationOA · Seen Sep 2026
- Consistent LogsOA · Seen Sep 2026
- Costliest ChocolateOA · Seen Sep 2026
- Server ManagementOA · Seen Sep 2026
- Cyber Beacon DetectionOA · Seen Aug 2026
Similar questions at other companies
- Maximize K-Element AND with an Increment BudgetAmazon · OA
- Minimum Cost to Reach a Target WeightChubb · OAChubb interview questions
- Minimum Operations to Sort with Rotations Then SwapsBank of New York Mellon · OA
- Optimal TransferSnowflake · OASnowflake interview questions
- Minimum Halvings for Alternating ParityIBM · OAIBM interview questions
- Server SelectionPoint72 · OAPoint72 interview questions
- Minimum Servers for an Exact LoadJP Morgan Chase · OAJP Morgan Chase interview questions
- Get Max Or SumMicrosoft · OAMicrosoft interview questions
- Fewest Steps to Build an Array from ZerosExpedia · OAExpedia interview questions
- Minimum Row Deletions to Prevent a Target ORInMobi · ONSITE INTERVIEWInMobi interview questions
Rippling interview experiences
- Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
- Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
- Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
- Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
- Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
- Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)