[LeetCode] 609. Find Duplicate File in System

김민우·2022년 9월 19일
0

알고리즘

목록 보기
12/189

- Problem

609. Find Duplicate File in System

- 내 풀이

class Solution:
    def findDuplicate(self, paths: List[str]) -> List[List[str]]:
        answer = collections.defaultdict(list)
        for path in paths:
            directory, *files = path.split()
            
            for f in files:
                name, extension = f.split('.')
                name = name + '.' + extension[:3]
                content = extension[3:]
                answer[content].append(directory + '/' + name)
        
        return list(filter(lambda x : len(x) > 1, answer.values()))

- 결과

profile
Pay it forward.

0개의 댓글