#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <map>
using namespace std;
class Solution {
public:
vector<string> findRepeatedDnaSequences(
string s) {
vector<string> res;
int i=
0,t=
0;
int n=s.size();
cout<<n<<endl;
if(n<=
10)
return res;
while(i<
9)
t= t<<
3 | (s[i++] &
7);
unordered_map<int,int> m;
while(i<n)
{
t= (t<<
3 | (s[i] &
7)) &
0x3fffffff;
m[t]++;
if(m[t]==
2)
{
res.push_back(s.substr(i-
9,
10));
}
i++;
}
return res;
}
};
int main()
{
Solution mys;
string s=
"AAAAACCCCCAAAAACCCCCCAAAAAGGGTTT";
vector<string> res=mys.findRepeatedDnaSequences(s);
for(
vector<string>::iterator it=res.begin();it!=res.end();it++)
cout<<*it<<endl;
return 0;
}