-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComparisonString.java
More file actions
31 lines (30 loc) · 937 Bytes
/
Copy pathComparisonString.java
File metadata and controls
31 lines (30 loc) · 937 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
import java.util.Scanner;
public class ComparisonString {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- > 0) {
int n = scanner.nextInt();
String s = scanner.next();
int maxg,maxl,currentg,currentl;
maxg = maxl=currentg=currentl=0;
for (int i = 0; i < n; i++) {
if(s.charAt(i)=='>'){
currentl=0;
currentg++;
if(currentg>maxg){
maxg=currentg;
}
}
else {
currentg=0;
currentl++;
if(currentl>maxl){
maxl=currentl;
}
}
}
System.out.println(Math.max(maxg,maxl)+1);
}
}
}