Tap here to switch tabs
Problem
Submissions

Problem: Majority Element II

med
30 min
Try to solve the Majority Element II problem.

Statement

Given an integer array nums, return all elements that appear more than ⌊ nums.length / 3 ⌋ times.

You may return the answer in any order.

Note: Could you solve the problem in linear time and in O(1) space?

Constraints:

  • 1<=1 <= nums.length <=5∗104<= 5 * 10^4

  • −109<=-10^9 <= nums[i] <=109<= 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Majority Element II

med
30 min
Try to solve the Majority Element II problem.

Statement

Given an integer array nums, return all elements that appear more than ⌊ nums.length / 3 ⌋ times.

You may return the answer in any order.

Note: Could you solve the problem in linear time and in O(1) space?

Constraints:

  • 1<=1 <= nums.length <=5∗104<= 5 * 10^4

  • −109<=-10^9 <= nums[i] <=109<= 10^9