Write a function to calculate the majority element in an array (an element that appears more than n/2 times).
HardProblem Statement
Write a function to calculate the majority element in an array (an element that appears more than n/2 times).
Sample Input
[2, 2, 1, 1, 1, 2, 2]
Sample Output
Majority Element: 2
Limits
Time: 2s · Memory: 256 MB