-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path609.py
More file actions
22 lines (22 loc) · 765 Bytes
/
Copy path609.py
File metadata and controls
22 lines (22 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Solution(object):
def findDuplicate(self, paths):
"""
:type paths: List[str]
:rtype: 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