Count triplets of indices where two adjacent subarrays have the same XOR.
Given an array of integers, count the number of triplets such that:
In other words, split a contiguous segment into two non-empty parts with the same XOR and count all valid choices of .
arr of length .Example 1
Input
arr = [2,3,1,6,7]
Output
4
Explanation
The valid triplets are (0,1,2), (0,2,2), (2,3,4), and (2,4,4). Each one splits a subarray into two parts with equal XOR.
Example 2
Input
arr = [1,1,1,1,1]
Output
10
Explanation
Many segments have equal XOR on both sides. Counting all valid index triplets gives 10.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.