Simply take a variable x=arr[0]
and do xor operation by traversing the rest of the elements . If an element has repeated then the x will become zero.
This way we know that the element has repeated previously . This also will just take o(n)
to scan through all of the elements in the original array.