Skip to content

Commit ec140e6

Browse files
authoredJan 17, 2024
Create 1207 unique number of occurrences.cpp
1 parent 8c403a3 commit ec140e6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
 

‎1207 unique number of occurrences.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
bool uniqueOccurrences(vector<int>& arr) {
4+
unordered_map<int,int> count;
5+
unordered_set<int> occurrence_unique;
6+
7+
for (int num:arr) {
8+
count[num]++;
9+
}
10+
11+
for (const auto& pair:count) {
12+
if (!occurrence_unique.insert(pair.second).second) {
13+
return false;
14+
}
15+
}
16+
return true;
17+
}
18+
};

0 commit comments

Comments
 (0)
Please sign in to comment.