Skip to content

Commit e8ba315

Browse files
authored
Create finding-the-users-active-minutes.py
1 parent b9d7362 commit e8ba315

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
import collections
5+
6+
7+
class Solution(object):
8+
def findingUsersActiveMinutes(self, logs, k):
9+
"""
10+
:type logs: List[List[int]]
11+
:type k: int
12+
:rtype: List[int]
13+
"""
14+
lookup = collections.defaultdict(set)
15+
for u, t in logs:
16+
lookup[u].add(t)
17+
result = [0]*k
18+
for _, ts in lookup.iteritems():
19+
result[len(ts)-1] += 1
20+
return result

0 commit comments

Comments
 (0)