-
Notifications
You must be signed in to change notification settings - Fork 0
/
DNA.cpp
50 lines (46 loc) · 988 Bytes
/
DNA.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <stack>
#include <cmath>
#include <assert.h>
#include <cstdio>
using namespace std;
// namespace std;
struct TreeNode{
char ch;
TreeNode* left;
TreeNode* right;
TreeNode(char id, TreeNode* l=NULL, TreeNode* r = NULL):ch(id),left(l),right(r) {}
};
class Solution {
public:
vector<string> findRepeatedDnaSequences(string s) {
map<string,int> dict;
vector<string> re;
if(s.size()<=10)
return re;
for(int i=0;i<s.size()-9;i++){
dict[s.substr(i,10)] += 1;
}
for(auto v:dict)
{
if(v.second>1)
re.emplace_back(v.first);
}
return re;
}
};
int main()
{
Solution sol;
sol.findRepeatedDnaSequences("AAAAACCCCCAAAAACCCCC");
return 0;
}