Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7150b2f

Browse files
Create 1207. Unique Number of Occurrences.cpp
1 parent f2b7808 commit 7150b2f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
bool uniqueOccurrences(vector<int>& arr) {
4+
unordered_map<int,int>mp;
5+
for(auto i:arr){
6+
mp[i]++;
7+
}
8+
unordered_set<int>s;
9+
bool flag = true;
10+
for(auto i:mp){
11+
if(s.find(i.second)!=s.end()){
12+
flag = false;
13+
break;
14+
}else{
15+
s.insert(i.second);
16+
}
17+
}
18+
return flag;
19+
}
20+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /