Here is the implementation:
function singleNumber(nums):
result = 0
for num in nums:
result = result XOR num
return result
This runs in time with space (excluding input). XOR is associative and commutative, so order doesn't matter.