https://programmers.co.kr/learn/courses/30/lessons/1845
#include <vector>
#include <set>
using namespace std;
int solution(vector<int> nums)
{
int answer = 0;
int size = nums.size();
set<int> numSet;
for(int n : nums) numSet.insert(n);
if(numSet.size() < size/2) return numSet.size();
else return size/2;
}
#include <vector>
#include <unordered_map>
using namespace std;
int solution(vector<int> nums)
{
unordered_map<int, int> hash;
for (auto num: nums) {
hash[num] += 1;
}
return min(hash.size(), nums.size() / 2);
}