정수형 데이터가 담긴 벡터에서 수들의 빈도수가 유니크한지 판단하는 문제
class Solution {
public:
bool uniqueOccurrences(vector<int>& arr) {
sort(arr.begin(), arr.end());
unordered_set<int> table{};
int tempCounter{0};
for (int i = 1; i < arr.size(); i++)
{
tempCounter++;
if (arr[i - 1] != arr[i])
{
if (0 < table.count(tempCounter))
{
return false;
}
table.insert(tempCounter);
tempCounter = 0;
}
}
if (0 < table.count(++tempCounter))
{
return false;
}
return true;
}
};