Easy · Arrays
Find majority element
Given an integer array nums of length n in which one value occurs more than n/2 times, return that value.
Examples
Example 1
[2,2,1,1,1,2,2]Output: majority = 2
Example 2
[3,3,4,2,3,3,3]Output: majority = 3
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.