This is a verified interview question from Linkdin. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Maximize Score by Performing Operations on an Integer Array - Linkdin Online Assessment" covers key patterns like Other.
"### Problem In a new game, players must maximize their score by performing operations on an integer array until its length is reduced to one. Starting with a score of zero, players must execute exactly n-1 operations. Each operation: - Decreases the array length by one - Requires selecting two indices x and y (where 1 ≤ x, y ≤ n) - Adds arr[x] ⊕ arr[y] to the score (where ⊕ represents bitwise XOR) - Removes either arr[x] or arr[y] from the array Return the highest possible score achievable through optimal operations. ### Function Description Complete the function findMaxScore in the editor with the following parameter(s): - int arr[n]: a list of integers ### Returns - long: the maximum possible score ### Example n = 3, arr = [3, 2, 1] Expected Output: 5 An optimal method: 1. Choose index 2 and 3, remove the 2nd index, score = arr[2] ⊕ arr[3] = 2 ⊕ 1 = 3, arr = [3, 1] 2. Choose index 1 and 2, remove the 1st index, score = arr[1] ⊕ arr[2] = 3 ⊕ 1 = 2, arr = [1] Sum the results and return the total score, 3+2 = 5."
Join thousands of developers practicing for Linkdin.