字典存储一下
class Solution(object):
def findRepeatedDnaSequences(self, s):
"""
:type s: str
:rtype: List[str]
"""
if len(s) <= 10:
return []
List = {}
for index in range(0,len(s)-9):
str_temp = s[index:index + 10]
if str_temp not in List:
List[str_temp] = 0
else:
List[str_temp] += 1
List_result = []
for (a,b) in List.items():
if b > 0:
List_result.append(a)
return List_result
t = Solution()
s = "AAAAAAAAAAA"
print(t.findRepeatedDnaSequences(s))