We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bf82919 commit 8c57f31Copy full SHA for 8c57f31
1207-unique-number-of-occurrences/1207-unique-number-of-occurrences.java
@@ -0,0 +1,31 @@
1
+class Solution {
2
+ public boolean uniqueOccurrences(int[] arr) {
3
+
4
+ HashMap<Integer, Integer> map = new HashMap<>();
5
+ ArrayList<Integer> list = new ArrayList<>();
6
7
+ for(int i=0; i<arr.length; i++)
8
+ {
9
+ if(map.containsKey(arr[i]))
10
11
+ map.put(arr[i],map.get(arr[i])+1);
12
+ }
13
+ else
14
15
+ map.put(arr[i],1);
16
17
18
19
+ for(Integer i:map.keySet())
20
21
+ if(list.contains(map.get(i)))
22
23
+ return false;
24
25
+ list.add(map.get(i));
26
27
+ return true;
28
29
30
31
+}
0 commit comments