Skip to content

Commit 6dda6df

Browse files
committed
Time: 3 ms (86.20%), Space: 7.9 MB (95.70%) - LeetHub
1 parent 713afb8 commit 6dda6df

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
bool uniqueOccurrences(vector<int>& arr) {
4+
int count[2005] = {}, unique = 0;
5+
for(int x: arr){
6+
if(count[x+1000]++ == 0)
7+
unique++;
8+
}
9+
10+
unordered_set<int> umap;
11+
for(int i=0; i<=2002; i++){
12+
if(count[i])
13+
umap.insert(count[i]);
14+
}
15+
16+
return umap.size() == unique;
17+
}
18+
};

0 commit comments

Comments
 (0)