Majority Element
Updated Feb 24, 2026
Problem
Return the element that appears more than n/2 times.
Constraints
1 <= nums.length <= 5 * 10^4
Examples
Example 1
Input:
{"nums": [3, 2, 3]}
Output:
3
Function Signature
def majorityElement(self, nums: list[int]) -> int
How to Submit
Implement a Solution class with a majorityElement method.
Your method will be called with the input parameters and should return the answer.