Count how many distinct XOR values can be formed by choosing three elements from the array.
Given an integer array nums, choose any three indices i, j, and k with i < j < k. Compute the value nums[i] XOR nums[j] XOR nums[k] for each such triplet.
Your task is to return the number of distinct XOR results that can be obtained from all valid triplets.
A result is considered distinct by its value, not by the indices that produced it.
nums.i < j < k.Example 1
Input
nums = [1, 2, 3]
Output
1
Explanation
Only one triplet exists: (1, 2, 3). Its XOR is 1 XOR 2 XOR 3 = 0, so there is exactly one distinct result.
Example 2
Input
nums = [1, 2, 3, 4]
Output
4
Explanation
The triplets produce XOR values {0, 1, 2, 7}. The number of unique results is 4.
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.