Untitled

 avatar
unknown
plain_text
a year ago
404 B
4
Indexable
class Solution {
public:
    vector<string> findRepeatedDnaSequences(string s) {
        vector<string>repeated;
        unordered_map<string,int>mp;
        for(int i=0;i+9<s.length();i++){
            string dna=s.substr(i,10);
            mp[dna]++;
            if(mp[dna]==2) repeated.push_back(dna); //whats more than 1 will always pass thru 2
        }
        return repeated;
    }
};
Editor is loading...
Leave a Comment