Skip to content

Commit 488a7da

Browse files
Create 1207-unique-number-of-occurrences.java
1 parent c440eb2 commit 488a7da

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public boolean uniqueOccurrences(int[] arr) {
3+
Map<Integer, Integer> map = new HashMap<>();
4+
for(int n: arr)
5+
map.put(n, map.getOrDefault(n, 0) + 1);
6+
7+
Set<Integer> set = new HashSet<>();
8+
for(int n: map.keySet()){
9+
if(set.contains(map.get(n)))
10+
return false;
11+
set.add(map.get(n));
12+
}
13+
return true;
14+
}
15+
}

0 commit comments

Comments
 (0)