Majority Element
Print the value that appears more than times, or -1 if none does. (The Boyer–Moore voting algorithm needs only extra memory.)
Input
, then integers.
Output
The majority value or -1.
Constraints
Sample 1
Input
7 2 2 1 1 1 2 2
Output
2
Sample 2
Input
2 1 2
Output
-1