-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path609.py
More file actions
18 lines (18 loc) · 700 Bytes
/
Copy path609.py
File metadata and controls
18 lines (18 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Solution:
def findDuplicate(self, paths: List[str]) -> List[List[str]]:
duplicated = {}
for path in paths:
str = path.split(' ')
folder = str[0] + '/'
for i in range(1, len(str)):
parentheses = str[i].find('(')
content = str[i][parentheses + 1:str[i].find(')')]
file = str[i][:parentheses]
if content not in duplicated:
duplicated[content] = []
duplicated[content].append(folder + file)
ret = []
for content, files in duplicated.items():
if len(files) > 1:
ret.append(files)
return ret