Skip to content

Practice Count Triplets That Can Form Two Arrays of Equal XOR

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1442
LeetCode Problem

Count Triplets That Can Form Two Arrays of Equal XOR

Problem Statement

Count triples of indices with 0 <= i < j <= k < arr.length such that the bitwise XOR of arr[i..j-1] equals the bitwise XOR of arr[j..k]. Both ranges are contiguous and inclusive at the displayed endpoints.

Source: Count Triplets That Can Form Two Arrays of Equal XOR on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
arr = [2,3,1,6,7]
Output
4

# Example 2

Input
arr = [1,1,1,1,1]
Output
10

Constraints

1 <= arr.length <= 300
1 <= arr[i] <= 10^8

Related LeetCode Problems

Practice more problems similar to Count Triplets That Can Form Two Arrays of Equal XOR.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.