Skip to content

Commit fda2b9e

Browse files
committed
Add Q187
1 parent a16a4fc commit fda2b9e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
vector<string> findRepeatedDnaSequences(string s) {
4+
vector<string> ans;
5+
unordered_map<string, int> m;
6+
for (int i = 0; i+9 < s.size(); ++i) {
7+
string sub = s.substr(i, 10);
8+
++m[sub];
9+
}
10+
for (auto&& p : m) {
11+
if (p.second > 1) {
12+
ans.push_back(p.first);
13+
}
14+
}
15+
return ans;
16+
}
17+
};

0 commit comments

Comments
 (0)