Hi there,
I'm interested in the following problem: there is an array of integers
that contains each element only once except for one element that
occurs exactly twice. Is there a way to find this element faster than
O(n*log n) and with constant extra memory? If no, how can I prove it?
Thanks in
if u know the range of values stored in array then
let me assume values 1 to k then u can calculate sum of numbers stored in
array in O(n) complexity.
after that apply formula
duplicate value= [k*(k+1)]/2 - sum of numbers stored in array
it will take O(1) constant time so total complexity