Given an array of integers, find the number of subarray which has length at least 3 where the bitwise XOR of first and last element in the subarray is equal to rest of the elements in the subarray. Can you think of a solution better than O(N^2)
I came up with O(n^2) solution using prefix_array. I was wondering if there is optimal solution than this because my solution cannot pass the last couple test cases.
If bitwise XOR of two edge elements is equal to XOR of inner elements, then XOR of entire subarray is zero.
So you can calculate prefix XOR sums, put them in dictionary, and "on the fly" check if proper pair sum already already exists in the dictionary.
Look at alike problem (usual sums, nor XOR), also contains size>=3 trick