This is a verified interview question from Amazon. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Number of Unique XOR Triplet - Amazon Online Assessment" covers key patterns like Arrays.
"You are given an integer array `nums`. A **XOR triplet** is defined as the XOR of three elements `nums[i]`, `nums[j]`, and `nums[k]`, where `i <= j <= k`. In other words, its value is: `nums[i] XOR nums[j] XOR nums[k]` Return the number of **distinct** XOR values that can be obtained from all valid triplets `(i, j, k)`. ### Example 1: **Input:** `nums = [1,3]` **Output:** `2` **Explanation:** The possible XOR values are: * `(0, 0, 0)` → `1 XOR 1 XOR 1 = 1` * `(0, 0, 1)` → `1 XOR 1 XOR 3 = 3` * `(0, 1, 1)` → `1 XOR 3 XOR 3 = 1` * `(1, 1, 1)` → `3 XOR 3 XOR 3 = 3` The distinct XOR values are `{1, 3}`, so the answer is `2`. ---"
Join thousands of developers practicing for Amazon.