find the unique element
You have an array consisting of 2n+1 elements, n elements in it are
paired, i.e they occur twice in the array, however there is one
element which only appears once in the array. You need to find that
number in a single pass using constant memory,assuming that all are
positive numbers.
paired, i.e they occur twice in the array, however there is one
element which only appears once in the array. You need to find that
number in a single pass using constant memory,assuming that all are
positive numbers.
XOR all the elements of the array.
ReplyDeleteyes correct
ReplyDelete