# Leetcode 229 - Majority element II

Note:

• Moore Voting Algo
• Initialize two nums and two counts as num1 = nums[0], count1 = 2, num2 = nums[0], count2 = 0.
• Start iterating.
• When either num1 or num2 is null. Set count to 1.
• When there is no match, subtract 1 from BOTH counts.
• When there is a match, plus one on the count.
• We still need to iterate again to check if the result left is more than [n/3].

Question:

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

Example:

Code:

Use Map