Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Majority Element

XPChallenge Points: 10
levelLevel: Easy

You are given an integer array nums of size n.
Your task is to find the majority element, which is the element that appears more than ⌊n / 2⌋ times in the array.
It is guaranteed that a majority element always exists in the array.

Example 1:

Input: nums = [4,5,4]

Output: 4

Example 2:

Input: nums = [1,1,2,2,2,1,1]

Output: 1

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result