Dsa
Bit Manipulation
Medium
XOR Sequence Compression
You are given an array of integers. Your task is to compress the sequence using bitwise XOR, such that you return the XOR of the entire array and the distinct XORs of all possible non-empty subsequences. Output the count of unique XOR values generated.
Example:
Input:
3 1 2 3
Output:
8
Explanation: The unique XOR results from the subsequences of [1, 2, 3] are 1, 2, 3, 3, 1, 0, 2, 1, resulting in a count of 8 unique values.
Key concepts
bit manipulationxorcompressed representation
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now