Skip to content

Commit

Permalink
create 0187-repeated-dna-sequences.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Maunish-dave committed Jan 19, 2023
1 parent cc969a0 commit 14a67dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cpp/0187-repeated-dna-sequences.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class Solution {
public:
vector<string> findRepeatedDnaSequences(string s) {

int n = s.size();
if(n <=10){ return {};}
vector<string> answer;

unordered_map<string,int> hash;

for(int i = 0;i<=s.size()-10;i++){
string ss = s.substr(i,10);
hash[ss]++;
if(hash[ss]==2){
answer.push_back(ss);
}
}

return answer;
}
};

0 comments on commit 14a67dd

Please sign in to comment.