https://leetcode.com/problems/majority-element-ii


Runtime: 8 ms, faster than 28.82% of Java online submissions for Majority Element II.
Memory Usage: 41.8 MB, less than 95.90% of Java online submissions for Majority Element II.


```java
import java.util.List;
import java.util.Map;
import java.util.HashMap;


class Solution {
    public List<Integer> majorityElement(int[] nums) {
      //2:56
      Map<Integer,Integer> counter = new HashMap<Integer,Integer>();
      for (int num : nums) {
        if (counter.containsKey(num)) {
          counter.put(num, counter.get(num) + 1);
        } else {
          counter.put(num,  1);
        }
      }

      List<Integer> results = new ArrayList<>();
      Integer threshold = nums.length / 3;
      for (Map.Entry<Integer,Integer> entry : counter.entrySet()){
        if (entry.getValue() > threshold) {
          results.add(entry.getKey());
        }
      }

      return results;
      //3:05
    }
}
```