CodeOath
← All problems

Majority Element

Easy
arrays

Return the element appearing more than n/2 times (guaranteed to exist).

Example:

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