Skip to content

Commit 14a67dd

Browse files
committed
create 0187-repeated-dna-sequences.cpp
1 parent cc969a0 commit 14a67dd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cpp/0187-repeated-dna-sequences.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public:
3+
vector<string> findRepeatedDnaSequences(string s) {
4+
5+
int n = s.size();
6+
if(n <=10){ return {};}
7+
vector<string> answer;
8+
9+
unordered_map<string,int> hash;
10+
11+
for(int i = 0;i<=s.size()-10;i++){
12+
string ss = s.substr(i,10);
13+
hash[ss]++;
14+
if(hash[ss]==2){
15+
answer.push_back(ss);
16+
}
17+
}
18+
19+
return answer;
20+
}
21+
};

0 commit comments

Comments
 (0)