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


Runtime: 8 ms, faster than 94.74% of C++ online submissions for Majority Element II.
Memory Usage: 16 MB, less than 9.50% of C++ online submissions for Majority Element II.


```cpp
#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
    vector<int> majorityElement(vector<int>& nums) {
      //2:49
      map<int, int> counter;
      for (int num : nums) {
        if (counter.find(num) == counter.end()) {
          counter[num] = 1;
        } else {
          counter[num] += 1;
        }
      }

      vector<int> results;
      int threshold = nums.size()/3;
      for (auto const& [key, value] : counter) 
      {
        if (value > threshold) {
          results.push_back(key);
        }
      }

      return results;
      //2:53
    }
};
```