609. Find Duplicate File in System
class Solution(object):
def findDuplicate(self, paths):
"""
:type paths: List[str]
:rtype: List[List[str]]
"""
content_path={}
for i in paths:
splits=i.split()
path=splits[0]
files=splits[1:]
for f in files:
index=f.find('(')
content=f[index+1:-1]
full_path=path.strip()+'/'+f[:index]
if content not in content_path:
content_path[content]=[full_path]
else:
content_path[content].append(full_path)
return [v for v in content_path.values() if len(v)>1]

浙公网安备 33010602011771号