class Solution:
def findDuplicate(self, paths: List[str]) -> List[List[str]]:
res = []
fileMap = {}
for path in paths:
strList = path.split(' ') #按空格切分
route = strList[0] #路径
for s in strList[1:]:
index = s.find('(')
file_name = s[ :index] #文件名
content = s[index+1 : -1] #内容
#若内容第一次出现在map,需要对路径集初始化
if content not in fileMap:
fileMap[content] = []
fileMap[content].append(route + '/' + file_name)
for f in fileMap:
if len(fileMap[f]) > 1:
res.append(fileMap[f])
return res