Easy · XOR Cancellation
Understand → Visualise → Practice.
XOR is associative and commutative, x XOR x = 0, and x XOR 0 = x. Pairs vanish regardless of order.
XOR every value into one accumulator; only the unpaired value remains.
answer = 0.
Order does not matter.
The final accumulator is the singleton.
O(n) time and O(1) space.
Addition or subtraction can overflow and does not cancel pairs in arbitrary order.
Read the full guide first: Bit Manipulation and Bitmask Patterns.
Guest mode lets you understand, visualise and run the sample tests. Create a free account to submit and save your solutions.