-
Notifications
You must be signed in to change notification settings - Fork 0
/
187.py
34 lines (27 loc) · 805 Bytes
/
187.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = ['"wuyadong" <[email protected]>']
class Solution(object):
def findRepeatedDnaSequences(self, s):
"""
:type s: str
:rtype: List[str]
"""
n = len(s)
sub_strs = dict()
for i in xrange(0, n):
if i+10 <= n:
sub_str = s[i:i+10]
if sub_str not in sub_strs:
sub_strs[sub_str] = 1
else:
sub_strs[sub_str] += 1
else:
break
l = []
for k, v in sub_strs.items():
if v >= 2:
l.append(k)
return l
if __name__ == "__main__":
print Solution().findRepeatedDnaSequences("AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT")