- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1207.java
24 lines (22 loc) · 772 Bytes
/
_1207.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
packagecom.fishercoder.solutions.secondthousand;
importjava.util.Arrays;
importjava.util.HashMap;
importjava.util.HashSet;
importjava.util.Map;
importjava.util.Set;
publicclass_1207 {
publicstaticclassSolution1 {
publicbooleanuniqueOccurrences(int[] arr) {
Map<Integer, Integer> map = newHashMap<>();
Arrays.stream(arr)
.forEach(
num -> {
map.put(num, map.containsKey(num) ? map.get(num) + 1 : 1);
});
Set<Integer> set = newHashSet<>();
returnmap.keySet().stream()
.mapToInt(key -> key)
.allMatch(key -> set.add(map.get(key)));
}
}
}