Minimum sum after doing many operations

24 Views Asked by At

We are given a list of numbers A. In this list if we perform one operation then the following things we can do:

1)select any subpart of the list. let say from L to R. 2) Let X be the xor of all the numbers of that sub part. 3) and now we can either replace A[L] with X or A[R] with X.

We can perform this operation any number of times.

So that we can a minimum sum of that list.

We have to find minimum sum after doing any number of time operations

example:

list: 1,2,3

sub part from [1,3] . Xor = 0 so the new list is 1,2,0 minimum sum = 3

I could not get how to start it. Please can someone help me in this