diff --git "a/leetcode3/\354\265\234\353\257\274\354\247\200/609.py" "b/leetcode3/\354\265\234\353\257\274\354\247\200/609.py" new file mode 100644 index 00000000..45299904 --- /dev/null +++ "b/leetcode3/\354\265\234\353\257\274\354\247\200/609.py" @@ -0,0 +1,20 @@ +from collections import defaultdict + +class Solution: + def findDuplicate(self, paths: List[str]) -> List[List[str]]: + content_map = defaultdict(list) + + for path in paths: + parts = path.split() + + directory = parts[0] + + for file in parts[1:]: + filename, content = file.split("(") + content = content[:-1] + + full_path = directory + "/" + filename + content_map[content].append(full_path) + + return [files for files in content_map.values() if len(files) > 1] + \ No newline at end of file