1 class Solution:
 2     def findRepeatedDnaSequences(self, s: str) -> 'List[str]':
 3         n = len(s)
 4         if n <= 10:
 5             return []
 6         res = []
 7         bstr = s[:10]
 8         dic = {bstr:1}
 9         i,j = 1,10
10         while j < n:
11             nstr = bstr[1:] + s[j]
12             if nstr not in dic:
13                 dic[nstr] = 1
14             else:
15                 dic[nstr] += 1
16             j += 1
17             bstr = nstr
18         for k,v in dic.items():
19             if v > 1:
20                 res.append(k)
21         return res

 

posted on 2019-12-11 12:34  Sempron2800+  阅读(138)  评论(0编辑  收藏  举报