Recall & Review
beginner Click to reveal answer
What does XOR operation do when applied between two same numbers?
XOR of two same numbers is 0 because each bit cancels out. For example, 5 ^ 5 = 0.
intermediate Click to reveal answer
Why do we use XOR to find two non-repeating elements in an array?
Because XOR of all elements cancels out repeating pairs, leaving XOR of the two unique elements. This helps us separate and find them.
intermediate Click to reveal answer
How do you find a bit that differs between two numbers using XOR?
XOR of two numbers has bits set where they differ. Finding the rightmost set bit in XOR helps separate the two numbers.
intermediate Click to reveal answer
What is the purpose of dividing elements into two groups based on a set bit in XOR?
It separates the two unique numbers into different groups so XOR in each group gives one unique number.
beginner Click to reveal answer
What is the time complexity of finding two non-repeating elements using XOR?
The time complexity is O(n) because we scan the array a few times with simple XOR operations.
What is the XOR of a number with 0?
✗ Incorrect
XOR with 0 leaves the number unchanged.
If XOR of all elements in an array is X, what does X represent when exactly two elements are unique?
✗ Incorrect
All repeating elements cancel out, leaving XOR of the two unique elements.
How do you find the rightmost set bit in a number X?
✗ Incorrect
X & (-X) isolates the rightmost set bit.
Why do we divide elements into two groups based on a set bit in XOR?
✗ Incorrect
This separates unique numbers into different groups for XOR.
What is the overall time complexity of the XOR method to find two unique elements?
✗ Incorrect
The method scans the array a few times linearly.
Explain step-by-step how XOR helps find two non-repeating elements in an array where all others repeat twice.
Think about how XOR cancels pairs and how bit differences help separate unique numbers.
You got /4 concepts.
Describe how to find the rightmost set bit of a number and why it is important in this problem.
Focus on bitwise operations and their role in grouping.
You got /3 concepts.
