182. Majority Element II
MediumArray
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.
Examples
Input: [1,1,1,3,3,2,2,2]
Output: [1,2]
Explanation: Both 1 and 2 appear 3 times, exceeding ⌊8/3⌋ = 2.
Constraints
- 1 <= nums.length <= 5 * 10^4
- -10^9 <= nums[i] <= 10^9
Loading...
Run checks all cases above. Submit evaluates all test cases.