class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param DNA string字符串 1
* @return string字符串vector
*/
vector<string> repeatedDNA(string DNA) {
// write code here
int len = 10;
vector<string> ans;
unordered_map<string, int> map;
for(int i = 0; i <= DNA.size() - 10; i++) {
string s = DNA.substr(i, 10);
map[s]++;
if(map[s] == 2)
ans.push_back(s);
}
return ans;
}
};