Question: Write C + + code and add majority.in file to the code so that I can compile my file. Print the majority element if it

Write C++ code and add majority.in file to the code so that I can compile my file.
Print the majority element if it exists and -1 otherwise.
Input
Sequence of integers (read till the end of file).
Output
Print the majority element if it exists and -1 otherwise.
Sample input 1
885858
Sample output 1
8
Sample input 2
12321
Sample output 2
-1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!