1. 程式人生 > >leetcode609. Find Duplicate File in System

leetcode609. Find Duplicate File in System

class Solution:
    def findDuplicate(self, paths):
        """
        :type paths: List[str]
        :rtype: List[List[str]]
        """
        d = {}
        for path in paths:
            this_dir = path.split(" ")  
            for i in this_dir[1:]:           
                file_name,content =
i.split("(") abs_path = "/".join([this_dir[0],file_name]) content = content[:-1] d[content] = d.get(content,[]) + [abs_path] return [v for v in d.values() if len(v)>1]