-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepetitions.cpp
More file actions
47 lines (45 loc) · 852 Bytes
/
Repetitions.cpp
File metadata and controls
47 lines (45 loc) · 852 Bytes
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
#include<iostream>
#include<string>
#include<stack>
#include<vector>
#include<ctype.h>
#include<algorithm>
#include <unordered_map>
using namespace std;
int main(){
string s;
cin>>s;
int a[4];
unordered_map<char, int> umap;
umap['A']=0;
umap['C']=0;
umap['T']=0;
umap['G']=0;
int n=s.length();
int i=0;
while(i<n){
char x=s[i];
int j=i+1;
int ct=1;
while(j<n){
if(x==s[j]){
ct++;
j++;
}
else{
break;
}
}
i=j;
if(ct>umap[x])
umap[x]=ct;
}
unordered_map<char, int>:: iterator p;
int maxx=-1;
for(p = umap.begin();p!=umap.end();p++){
if(maxx<p->second)
maxx=p->second;
}
cout<<maxx;
return 0;
}