OA Question || XOR
Anonymous User
378

You are given an array A of N integers and an integer K.
You can perform the following operation any number of times:

Choose an index i
Choose any non-negative integer Y
Replace Ai by Ai XOR Y

While doing these operations, the sum of all Y used should not exceed K.

Your task is to maximize the sum of all elements of the array. Output the maximum sum.

Examples:

N = 3, K = 7, A = [2, 4, 3]
Output: 16

N = 5, K = 5, A = [8, 7, 1, 8, 2]
Output: 31

Can anyone suggest the approach to this question?

Comments (1)