Company: Cisco_21_jan
Difficulty: medium
Maximize Score by Array Reduction 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, where n is the initial length of the array. Each operation consists of the following steps: Select two elements, let's call them x and y , from the current array. Add the value of x XOR y to the total score. ( XOR represents the bitwise XOR operation). Remove either x or y from the array. The array's size decreases by one. Your task is to find and return the highest possible score achievable through an optimal sequence of operations. Examples Example 1: Input: arr = [3, 2, 1] Output: 5 Explanation: An optimal sequence of operations is as follows: Start with arr = [3, 2, 1] and score = 0 . Choose elements 2 and 1 . Add 2 XOR 1 = 3 to the score. Remove 2 from the array. Current score: 3 . Current array: [3, 1] . Choose elements 3 an