Challenge: Majority Element

Solve the Majority Element Problem.

We'll cover the following

Problem


Majority Element Problem

Check whether a given sequence of numbers contains an element that appears more than half of the times.

Input: A sequence of nn integers.

Output: 11, if there is an element that is repeated more than n/2n/2 times, and 00 otherwise.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.