13. Unique Number of Occurrences
My Approach
Time and Auxiliary Space Complexity
Code (C++)
class Solution {
public:
bool isFrequencyUnique(int n, int arr[]) {
unordered_map<int, int> freq;
unordered_set<int> uniqueSet;
for (int i = 0; i < n; ++i)
++freq[arr[i]];
for (auto i : freq)
uniqueSet.insert(i.second);
return freq.size() == uniqueSet.size();
}
};Contribution and Support
Last updated