본문 바로가기

IT/코딩테스트

[Leetcode] 1817. Finding the Users Active Minutes

728x90

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

 

Finding the Users Active Minutes - LeetCode

Can you solve this real interview question? Finding the Users Active Minutes - You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the

leetcode.com

class Solution:
    def findingUsersActiveMinutes(self, logs: List[List[int]], k: int) -> List[int]:
        result = []
        
        action = {}
        for l in logs:
            if action.get(l[0], None) is None:
                action[l[0]] = set()

            action[l[0]].add(l[1])

        for i in range(k):
            result.append(0)

        for key, value in action.items():
            result[len(value) - 1] +=1

        return result
728x90