DEV Community

Miss Pooja Anilkumar Patel
Miss Pooja Anilkumar Patel

Posted on

1207. Leetcode Solution in CPP

class Solution {
public:
    bool uniqueOccurrences(vector<int>& A) {
        unordered_map<int, int> m;
        for (int n : A) m[n]++;
        unordered_set<int> s;
        for (auto &p : m) {
            if (s.count(p.second)) return false;
            s.insert(p.second);
        }
        return true;
    }
};
Enter fullscreen mode Exit fullscreen mode

leetcode

challenge

Here is the link for the problem:
https://leetcode.com/problems/unique-number-of-occurrences/

Top comments (0)