Here my c++ code,easy understand


  • 0
    K

    class Solution {
    public:
    vector<string> findRepeatedDnaSequences(string s) {
    vector<string> res;
    if(s.size()<10) return res;
    map<string,int> strmap;
    string subs;
    for(int i=0;i<s.size()-9;i++){
    subs=s.substr(i,10);
    if(strmap[subs]++==1){
    res.push_back(subs);
    }
    }
    return res;
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.