# 187. 重复的DNA序列

<https://leetcode-cn.com/problems/repeated-dna-sequences/>

## 解法一：

由于检测的是连续序列，因此只需i一次遍历0到n-10，每次取连续的十位`[i:i+10]`，用哈希表即可。

```python
class Solution:
    def findRepeatedDnaSequences(self, s: str) -> List[str]:
        n = len(s)
        res = []
        hashMap = {}  #键为字符串，值为出现次数
        for i in range(n-9):
            if s[i:i+10] in hashMap:
                hashMap[s[i:i+10]] += 1
            else:
                hashMap[s[i:i+10]] = 1
        for key in hashMap:
            if hashMap[key] > 1:
                res.append(key)
        return res
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cai-sen-se.gitbook.io/leetcode/1-200/187.-zhong-fu-de-dna-xu-lie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
