Created
October 1, 2018 18:30
-
-
Save uncountablecat/edfe2f2f7f1909d91e59a2873cc2e294 to your computer and use it in GitHub Desktop.
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 findRepeatedDnaSequences(self, s): | |
""" | |
:type s: str | |
:rtype: List[str] | |
""" | |
Map = dict() | |
for i in range(len(s)-9): | |
if s[i:i+10] not in Map.keys(): | |
Map[s[i:i+10]] = 1 | |
else: | |
Map[s[i:i+10]] += 1 | |
ret = list() | |
for key in Map.keys(): | |
if Map[key] > 1: | |
ret.append(key) | |
return ret | |
# brute force method is quadratic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment