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