Majority Element

Easy
Arrays Array Hash Table Sorting

Given an array, find the element that appears more than n/2 times.

Constraints

n ≥ 1, majority always exists

Examples

Example 1:
Input: 3 2 3
Output: 3
Example 2:
Input: 2 2 1 1 1 2 2
Output: 2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.