<jupyter_start><jupyter_text>All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.Write a function to find all the 10-letter-long sequences (substrings) that occur more than once in a DNA molecule.**Example:**    Input: s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"        Output: ["AAAAACCCCC", "CCCCCAAAAA"]  Thought1. The first method I'm using hash table to store every sequence that hasn't used before. Otherwise, the sequences have been used will store into result. And there might contain more than two times in the test DNA sequence, so I utilized set() to reduce the duplicate cases. There are several redudant manipulation in this method. I am going to find another way to reduce the space or time complexity.2. Using two has map. Then the efficiency gets way much higher.<jupyter_code>def findRepeatedDnaSequences(self, s):
    """
    :type s: str
    :rtype: List[str]
    """
    dic={}
    res=[]
    for i in range(len(s)-9):
        if s[i:i+10] in dic:
            res.append(s[i:i+10])
        else:
            dic[s[i:i+10]]=1

    return list(set(res))
def findRepeatedDnaSequences(self, s):
    """
    :type s: str
    :rtype: List[str]
    """
    visited=set()
    repeated=set()

    for i in range(len(s)-9):
        subs=s[i:i+10]
        if subs in visited:
            repeated.add(subs)
        visited.add(subs)

    return list(repeated)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0984354628422425, 'fraction_numerical': 0.009778357235984355, 'mean_word_length': 3.25207756232687, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '565548', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 486, 'n_tokens_neox': 470, 'n_words': 183, 'path': '187. Repeated DNA Sequences.ipynb', 'repo_name': 'kkoo1122/Leetcode_Practice', 'size': '1534'}