XOR TRIPLETS

Given a array of integers A of size N.

A triplet (i, j, k), i <= j <= k is called a power triplet if A[i] ^ A[i+1] ^….A[j-1] = A[j] ^…..^A[k].

Where, ^ denotes bitwise xor.

Return the count of all possible power triplets.



Input Format

The first argument given is the integer array A.

Output Format

Return the count of all possible power triplets.

Constraints

1 <= N <= 100000
1 <= A[i] <= 100000

For Example

Input 1:
    
    A = [5, 2, 7]
    
Output 1:
    2
Explaination 1:
    All possible power triplets are:
        1. (1, 2, 3) ->  A[1] = A[2] ^ A[3]
        2. (1, 3, 3) ->  A[1] ^ A[2] = A[3]
Input 2:
    A = [1, 2, 3]
Output 2:
    2
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving XOR TRIPLETS on Interview Code Editor
Sign Up
to access hints and editorial solutions for XOR TRIPLETS

Discussion


Loading...
Click here to start solving coding interview questions