← Interval & Math

Micro-Drill #251 — XOR cancel (find single number)

Interval & Math Target: 5s

XOR cancellation finds the element appearing an odd number of times. O(n) time, O(1) space — no hash map needed.

result = 0
for x in nums:
    result ^= x
# pairs cancel: a ^ a = 0, only unique remains

Type it from memory. Go.

Practice Problems

Related Coding Drills

← Micro #250 Micro #252 →