Majority Element II Problem

Majority Element II Problem — ExecCode Easy DSA Practice

Solve the Majority Element II problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given an integer array of size n, find all elements that appear more than ⌊n / 3⌋ times.

Examples

Input {"nums": [3, 2, 3]}; Output [3]. Input {"nums": [1]}; Output [1]. Input {"nums": [1, 2]}; Output [2, 1]

Constraints

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

Practice Majority Element II free on ExecCode. Browse DSA problems, topic map, and placement guides.