We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d5e7145 commit cc8a76eCopy full SHA for cc8a76e
Python/unique-number-of-occurrences.py
@@ -0,0 +1,31 @@
1
+# Time: O(n)
2
+# Space: O(n)
3
+
4
+import collections
5
6
7
+class Solution(object):
8
+ def uniqueOccurrences(self, arr):
9
+ """
10
+ :type arr: List[int]
11
+ :rtype: bool
12
13
+ count = collections.Counter(arr)
14
+ lookup = set()
15
+ for v in count.itervalues():
16
+ if v in lookup:
17
+ return False
18
+ lookup.add(v)
19
+ return True
20
21
22
23
24
+class Solution2(object):
25
26
27
28
29
30
31
+ return len(count) == len(set(count.itervalues()))
0 commit comments