Majority Element II

Given an integer array nums of size n, return all elements that appear more than n/3 times.

Input Format

nums = array of integers

Output Format

elements appearing more than n/3 times

Constraints

  • 1 <= nums.length <= 5*10^4; -10^9 <= nums[i] <= 10^9

Examples

Example 1:

Input:

nums = [3,2,3]

Output:

[3]

Explanation:

3 appears more than n/3 times.

Loading...
Majority Element II - Arrays DSA Problem