Skip to content

Commit 8a92c3f

Browse files
authored
Create 609. Find Duplicate File in System.py
1 parent 5fa7527 commit 8a92c3f

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
-
6+
7+
2. 시간복잡도 :
8+
O(n * m)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
from collections import defaultdict
15+
16+
class Solution:
17+
def findDuplicate(self, paths: List[str]) -> List[List[str]]:
18+
content_to_paths = defaultdict(list)
19+
20+
for path_info in paths:
21+
parts = path_info.split()
22+
23+
directory = parts[0]
24+
25+
for file_info in parts[1:]:
26+
file_name, content = file_info.split("(")
27+
content = content[:-1] # 마지막 ')' 제거
28+
29+
full_path = directory + "/" + file_name
30+
content_to_paths[content].append(full_path)
31+
32+
return [
33+
file_paths
34+
for file_paths in content_to_paths.values()
35+
if len(file_paths) >= 2
36+
]

0 commit comments

Comments
 (0)