Statementâ–¼
Given an array, nums
, having n integers, return the majority element. An element will be considered a majority element if it occurs more than ⌊n/2⌋ times in the array.
Note: It is safe to assume that the majority element always exists in the array.
Constraints
- n==
nums.length
- 1≤n≤5∗104
- −109≤
nums[i]
≤109