Leetcode 1945 Solution

This article provides solution to leetcode question 1945 (finding-the-users-active-minutes)

https://leetcode.com/problems/finding-the-users-active-minutes

Solution

class Solution:
    def findingUsersActiveMinutes(self, logs: List[List[int]], k: int) -> List[int]:
        m = collections.defaultdict(set)

        for user, t in logs:
            m[user].add(t)

        ans = [0] * k
        for user, times in m.items():
            ans[len(times) - 1] += 1

        return ans