Skip to content

Instantly share code, notes, and snippets.

@vrat28
Created May 18, 2021 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrat28/6f63fe421c64cca2c1d0aad6781497b3 to your computer and use it in GitHub Desktop.
Save vrat28/6f63fe421c64cca2c1d0aad6781497b3 to your computer and use it in GitHub Desktop.
Find Duplicate Files in File System
class Solution:
def findDuplicate(self, paths: List[str]) -> List[List[str]]:
contMap, ans = defaultdict(list), []
for pStr in paths:
sep = pStr.split(" ")
for i in range(1, len(sep)):
parts = sep[i].split('(')
cont = parts[1][:-1]
contMap[cont].append(sep[0] + '/' + parts[0])
for v in contMap.values():
if len(v) > 1: ans.append(v)
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment