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
Core interview problems are free with a full runner and lessons; Pro opens the complete library.