-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB_Comparison_String.cpp
More file actions
60 lines (54 loc) · 1.1 KB
/
B_Comparison_String.cpp
File metadata and controls
60 lines (54 loc) · 1.1 KB
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
51
52
53
54
55
56
57
58
59
60
// #include<bits/stdc++.h>
// using namespace std;
// int main(){
// int t;
// cin>>t;
// while(t--){
// int n;
// cin>>n;
// string s;
// cin>>s;
// int ml=0,mr=0;
// for(int i=0;i<n;i++){
// int cl=0,cr=0;
// while(s[i]=='>'){
// cr++;
// i++;
// }
// if(cr>mr)mr=cr;
// while(s[i]=='<'){
// cl++;
// i++;
// }
// if(cl>ml)ml=cl;
// }
// cout<<max(mr,ml)+1<<endl;
// }
// }
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int cm = 1, ca = 1;
for (int i = 1; i < n; i++) {
if (s[i] == s[i - 1]) {
ca++;
} else {
cm = max(cm, ca);
ca = 1;
}
}
cm = max(cm, ca);
cout << cm + 1 << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}