//1207. 独一无二的出现次数
//使用map计数
//然后使用set判重
class Solution {
public:
bool uniqueOccurrences(vector<int>& arr) {
unordered_map<int, int>ns;
for (auto x : arr)
ns[x]++;
unordered_set<int>s;
for (auto x : ns) {
if (s.count(x.second)) return false;
s.emplace(x.second);
}
return true;
}
};
LeetCode1207. 独一无二的出现次数
最新推荐文章于 2024-07-21 08:37:44 发布