Company: Cisco_23_jan
Difficulty: medium
Maximize Score by Array Operations Problem Description 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 consists of the following steps: Decreases the array length by one. Requires selecting two indices x and y (where x ≤ y ). 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. Example Input: n = 3 arr = [3, 2, 1] Expected Output: 5 Explanation: An optimal method is as follows: Initial array: [3, 2, 1] , score: 0 . Choose elements 2 and 1 . Add 2 ⊕ 1 = 3 to the score. Remove the element 2 . Current array: [3, 1] , score: 3 . Choose elements 3 and 1 . Add 3 ⊕ 1 = 2 to the score. Remove the element 3 . Current array: [1] , score: 3 + 2 = 5 . The total score