Are you kidding? Did you test your solution? Suppose, A = {1, 4, 5, 6, 2, 2}. Sum of the elements is S=20, X_SUM = 6. Result of your algo is (20-6)/2=7 instead if correct 2.
On 20 окт, 14:49, 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.