1207_UniqueNumberofOccurrences - a920604a/leetcode GitHub Wiki
categories: leetcode comments: false tags:
- hash table title: 1207. Unique Number of Occurrences
class Solution {
public:
bool uniqueOccurrences(vector<int>& arr) {
unordered_map<int, int> mp;
unordered_set<int> s;
for(int a:arr) mp[a]++;
for(auto it = mp.begin() ; it!=mp.end() ; ++it)
{
if(s.count(it->second)) return false;
s.insert(it->second);
}
return true;
}
};
- time complexity
O(n)
- space complexity
O(n)