#3513

Number of Unique XOR Triplets I

medium · 26.5% accepted · 50 likes · top 5%

array · math · bit manipulation

Description

You are given an integer array nums of length n, where nums is a permutation of the numbers in the range [1, n].

A XOR triplet is defined as the XOR of three elements nums[i] XOR nums[j] XOR nums[k] where i <= j <= k.

Return the number of unique XOR triplet values from all possible triplets (i, j, k).

Solution