On Sep 7, 12:43 pm, Sandy <sandy.wad...@gmail.com> wrote: > You have an array in which every number is repeated odd number of times > except one. Write a function to find that one element in O(n) time. > > -- > > *Sandeep Kumar,* > ( > Mobile+91-9866507368begin_of_the_skype_highlighting +91-9866507368 > > *“I believe in smart work, Believe Me”*
hey i m just sending something i wrote int (a[],n) //////// a is the array u r inputting { for(i=0;i<n;i++) { if(utility(a,n,1,a[i])==1) ///u r testing each value from the start { return a[i]; //as soon as u get y=1 tht means odd no repeat break; } } } int utility(a[],n,y,number) { if(n==-1&&y==1) ///base cae { return 1; } if(n==-1&&y==0) ///base case { return 0; } else { n--; if(number==a[n]&&y=1) { y=0; } if(number==a[n]&&y=0) { y=1; } util(a,n-1,y,x);` } } -- 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.