Given an array with N elements. We know that one of those elements repeats itself at least N/2 times.
We don’t know anything about the other elements . They may repeat or may be unique .
Is there a way to find out the element that repeats at least N/2 times in a single pass or may be O(N)?
No extra space is to be used .
st0le answered the question, but here’s a 5minute implementation:
And here’s a fun explanation (more fun than reading the paper, at least): http://userweb.cs.utexas.edu/~moore/best-ideas/mjrty/index.html