@Mahesh: Let's try this on 1, 2, 3, 4, 4. Then S = 14 and X_SUM = 0. But the duplicate element is 4, not (14-0) / 2 = 7.
Dave On Oct 20, 5:49 am, Mahesh_JNU <mahesh.jnumc...@gmail.com> wrote: > 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.