Created
May 18, 2021 15:22
-
-
Save vrat28/6f63fe421c64cca2c1d0aad6781497b3 to your computer and use it in GitHub Desktop.
Find Duplicate Files in File System
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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