Given a Cyclic Array 'A' of size N, we have to choose a 'cyclic subarray' R of length N itself in such a way that the value of R[0] + R[0]^R[1] + R[0]^R[1]^R[2] + ......... + R[0]^R[1]^R[2]^.....R[N-1]^R[N] is maximum.
[Note: ^ represents bitwise XOR.]
Example of Cyclic Array and Cyclic Subarray: Let's take a Cyclic Array, A = [2, 5, 1, 7, 9]
for index 0; [2, 5, 1, 7, 9] and [2, 9, 7, 1, 5] are two cyclic Subarray of length(A).
Similarly, for index 1; [5, 1, 7, 9, 2] and [5, 2, 9, 7, 1] are another two cyclic Subarray of length(A).
Similarly, for index 2; [1, 7, 9, 2, 5] and [1, 5, 2, 9, 7] are another two cyclic Subarray of length(A).
and so on.
What should be the approach to solve this problem? I tried Applying Trie and Gaussian Elimination but I am not able to come up with a solution.