An array has n elements. One element appears more than n/2 times. You can only compare two elements for equality. How do you find the majority element with O(n) comparisons?
Quick Answer & Explanation
Boyer-Moore Majority Vote: maintain
The answer to this riddle is Boyer-Moore Majority Vote: maintain. Difficulty: Hard · Solved by 18,943 puzzle lovers.