Short Python


  • 0
    class Solution(object):
        def findDuplicate(self, paths):
            """
            :type paths: List[str]
            :rtype: List[List[str]]
            """
            dic = collections.defaultdict(list)
            for path in paths:
                p = path.split()
                root = p[0]
                for file in p[1:]:
                    idx = file.find("(")
                    fn, content = file[:idx], file[idx:]
                    dic[content].append(root + "/" + fn)
            return [dic[key] for key in dic if len(dic[key]) > 1]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.