One of my friend was asked this question in an interview -
It is impossible to solve this problem without making comparisons. Some modern languages do have set difference and other aggregate operators, but they work by internally making comparisons. If the total array size is odd (not the case here) then it does work to xor the elements together. I suppose the question of whether the ALU's xor op should be considered a comparison is debatable.
And without specifying a language, you can't refer to a library, so the only possible solution is a comparison-based pseudo-code exposition.
So here you go:
a <- first element
a_count = 1
b_count = 0
loop over remaining elements
if element != a
b <- element
++b_count
else
++a_count
if found_result
break loop
end loop
found_result
if a_count > 1 and b_count > 0
the unique one is b
return true
if b_count > 1 and a_count > 0 # a_acount actually always > 0
the unique one is a
return true
return false