i don't think it's of O(n) for even it's actually easy. Take the xor of all the elements you will left with the element which appears odd number of times. O(n) but for the odd case, we need to use extra space. Use hash map to keep the count of each number and take the odd one out, i mean the even one.
On Wed, Sep 7, 2011 at 11:06 PM, Rahul Thankachan <rahul29ma...@gmail.com>wrote: > > > 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”* > > > sry i made the logic for the opp for even instead..u just need to > change sm values...u will get it :):) its simple.. > > -- > 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. > > -- 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.