for(i=0 to n) { if(a[abs(a[i])-1]>0) a[abs(a[i])-1] = -a[abs(a[i])-1]; else printf("%d",a[abs(a[i])]); }
space : o(n) time : o(1) On Fri, Aug 19, 2011 at 12:45 AM, *$* <gopi.komand...@gmail.com> wrote: > How to find duplicate element (only one element is repeated) from an array > of unsorted positive integers.. > time complexity .. O(n) > space .. o(1). > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@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. > -- *Narayanan S,* B.E., C.S.E., (final year), College Of Engineering Guindy, Anna University, Chennai-25. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@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.