I was asked this question in recent ByteDance OA
Q) An array of n integers, arr, is given. Pick any index then calculate the XOR of the array from that index through the highest index. Append the value to the array. Repeat this process zero or more times. Determine the highest value possible.
Example
Input:
n = 5
[8, 2, 4, 12, 1]
Output:
14
Input:
n = 4
[0, 2, 5, 1]
Output:
7
Can anyone solve this.