<p>The <strong>DNA sequence</strong> is composed of a series of nucleotides abbreviated as <code>&#39;A&#39;</code>, <code>&#39;C&#39;</code>, <code>&#39;G&#39;</code>, and <code>&#39;T&#39;</code>.</p>

<ul>
	<li>For example, <code>&quot;ACGAATTCCG&quot;</code> is a <strong>DNA sequence</strong>.</li>
</ul>

<p>When studying <strong>DNA</strong>, it is useful to identify repeated sequences within the DNA.</p>

<p>Given a string <code>s</code> that represents a <strong>DNA sequence</strong>, return all the <strong><code>10</code>-letter-long</strong> sequences (substrings) that occur more than once in a DNA molecule. You may return the answer in <strong>any order</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
<pre><strong>Input:</strong> s = "AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT"
<strong>Output:</strong> ["AAAAACCCCC","CCCCCAAAAA"]
</pre><p><strong class="example">Example 2:</strong></p>
<pre><strong>Input:</strong> s = "AAAAAAAAAAAAA"
<strong>Output:</strong> ["AAAAAAAAAA"]
</pre>
<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
	<li><code>s[i]</code> is either <code>&#39;A&#39;</code>, <code>&#39;C&#39;</code>, <code>&#39;G&#39;</code>, or <code>&#39;T&#39;</code>.</li>
</ul>

class Solution {
private:
    
public:
    vector<string> findRepeatedDnaSequences(string s) {
        int k = 10 , n = s.size();
        vector<string> arr;
        if(n < k)
            return arr;
        
        unordered_map<int,int> charToInt;
        unordered_set<string> ans;
        unordered_set<int>st;
        charToInt['A'-'A']=0;
        charToInt['C'-'A']=1;
        charToInt['G'-'A']=2;
        charToInt['T'-'A']=3;
        
        for(int i=0;i<=n-k;i++){
            int hash = 0;
            string temp;
            for(int j=i;j<i+k;j++){
                temp.push_back(s[j]);
                hash = hash<<2;
                // hash|=charToInt[s[j]-'A'];
                hash+=charToInt[s[j]-'A'];
            }
            if(st.find(hash)!=st.end()){
                ans.insert(temp);
            }
            st.insert(hash);
        }
        for(auto x : ans){
             arr.push_back(x);
        }
        return arr;
    }
};
13903