2 parents f0605ec + 8a92c3f commit a55a91eCopy full SHA for a55a91e
1 file changed
leetcode3/최원준/609. Find Duplicate File in System.py
@@ -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