609. Find Duplicate File in Syst

2019-05-31  本文已影响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
上一篇下一篇

猜你喜欢

热点阅读