both problems can be done in O(n)
pick the first two elements count the number of their appearances in the
array ( O(n) )
if they are not the result we now that there is an element that is repeated
n times in 2n-1 elements and we can do the moore's algorithm for finding it
here's a link to this algorithm:
userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to