美文网首页
609. Find Duplicate File in Syst

609. Find Duplicate File in Syst

作者: 一个想当大佬的菜鸡 | 来源:发表于2019-05-31 20:30 被阅读0次

    609. Find Duplicate File in System
    class Solution(object):
        def findDuplicate(self, paths):
            """
            :type paths: List[str]
            :rtype: List[List[str]]
            """
            mydic = {}
            for path in paths:
                temp = path.split(' ')
                for i in range(1, len(temp)):
                    temp_path = temp[0] + '/' + temp[i]
                    temp_path = temp_path.split('(')
                    if temp_path[1] in mydic:
                        mydic[temp_path[1]].append(temp_path[0])
                    else:
                        mydic[temp_path[1]] = [temp_path[0]]
            res = []
            for i in mydic.values():
                if len(i) == 1:
                    continue
                res.append(i)
            return res
    

    相关文章

      网友评论

          本文标题:609. Find Duplicate File in Syst

          本文链接:https://www.haomeiwen.com/subject/zgggtctx.html