Skip to content

Instantly share code, notes, and snippets.

@uncountablecat
Created October 1, 2018 18:30
Show Gist options
  • Save uncountablecat/edfe2f2f7f1909d91e59a2873cc2e294 to your computer and use it in GitHub Desktop.
Save uncountablecat/edfe2f2f7f1909d91e59a2873cc2e294 to your computer and use it in GitHub Desktop.
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