Here's the complete solution:
function singleNumber(nums)
result := 0
for each num in nums
result := result XOR num
return result
This runs in time and space. The XOR operator (boolean logic at the bit level) cancels duplicate pairs, isolating the unique element. XOR turns a hard problem into three lines of code.