Find all 10-letter-long sequences and save into hash table.
Return sequences which's counter > 1.
class Solution:
def findRepeatedDnaSequences(self, s: str) -> List[str]:
seen = defaultdict(int)
for i in range(len(s) - 10 + 1):
seen[s[i:i+10]] += 1
return filter(lambda k: seen[k] > 1, seen.keys())
No comments:
Post a Comment