Just add the number of the array and let the sum is S. Its complexity is O(n). Now XOR all elements of the array and say the result is X_SUM.Its complexity is O(n). Now the duplicate element is = (S - X_SUM)/2
On Wed, Oct 20, 2010 at 4:14 PM, Asquare <anshika.sp...@gmail.com> wrote: > @Anirvana - In context to the XOR method u suggested, could u plz > explain why does it so happen.. ?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Mahesh Giri -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.