Count Triplets That Can Form Two Arrays of Equal XOR

Given an array of integers, the task is to count the number of triplets (i, j, k) such that 0 <= i < j <= k < arr.length and the XOR of the subarray from index i to j-1 is equal to the XOR of the subarray from index j to k.

Constraints

  • 1 <= arr.length <= 300
  • 1 <= arr[i] <= 10^8
Saving… · 2 lines
class Solution:
def countTriplets(self, arr: List[int]) -> int:
Console

Click Run to execute sample tests.