solution.md 1.5 KB
Newer Older
ToTensor's avatar
ToTensor 已提交
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
# 重复的DNA序列

<p>所有 DNA 都由一系列缩写为 <code>'A'</code><code>'C'</code><code>'G'</code><code>'T'</code> 的核苷酸组成,例如:<code>"ACGAATTCCG"</code>。在研究 DNA 时,识别 DNA 中的重复序列有时会对研究非常有帮助。</p>

<p>编写一个函数来找出所有目标子串,目标子串的长度为 10,且在 DNA 字符串 <code>s</code> 中出现次数超过一次。</p>

<p> </p>

<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
<strong>输出:</strong>["AAAAACCCCC","CCCCCAAAAA"]
</pre>

<p><strong>示例 2:</strong></p>

<pre>
<strong>输入:</strong>s = "AAAAAAAAAAAAA"
<strong>输出:</strong>["AAAAAAAAAA"]
</pre>

<p> </p>

<p><strong>提示:</strong></p>

<ul>
	<li><code>0 <= s.length <= 10<sup>5</sup></code></li>
	<li><code>s[i]</code><code>'A'</code><code>'C'</code><code>'G'</code><code>'T'</code></li>
</ul>


## template

```python
class Solution:
    def findRepeatedDnaSequences(self, s: str) -> List[str]:
        n = len(s)
        res = []
        dic = {}
        for i in range(n - 9):
            if s[i : i + 10] not in dic:
                dic[s[i : i + 10]] = 1
            else:
                dic[s[i : i + 10]] += 1
            if dic[s[i : i + 10]] == 2:
                res.append(s[i : i + 10])
        return res


```

## 答案

```python

```

## 选项

### A

```python

```

### B

```python

```

### C

```python

```