This problem came in their coding challenge. Can anyone solve it ?
Problem Statement
You are given 2 integer array, A and B, of length n. Your task is to maximize xor-sum of the arrays.
Xor-sum of 2 arrays is defined as the S = (A[0] ^ B[0]) + (A[1] ^ B[1]) + ..... + (A[n — 1] ^ B[n — 1]). Expression (x ^ y) is means applying Bitwise Excluding Or operation on x and y.
There is a twist in the problem. You are allowed to reverse at most one subarray of array A. Find maximum possible Xor-sum.
Constraints
1 <= n <= 5000
1 <= Ai <= 10^5
1 <= Bi <= 10^5
Test Case
Q) A = {1, 2} , B = {1, 2}
Ans) 6 (Reverse whole of subarray A and then find Xor-sum)