-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain2.java
More file actions
33 lines (30 loc) · 793 Bytes
/
Main2.java
File metadata and controls
33 lines (30 loc) · 793 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
import java.util.Scanner;
/**
* Created by LXF on 2017/8/12.
*/
public class Main2 {
public static int getMaxNum(String str) {
int max = 0;
int i = 0;
while (i+1 < str.length()) {
int count = 0;
int j = i;
while (j+1 < str.length()) {
if (str.charAt(j) - str.charAt(j + 1) != 0) {
j++;
count++;
}
else
break;
}
max = Math.max(max, count+1);
i = j+1;
}
return max;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String string = scanner.nextLine();
System.out.println(getMaxNum(string));
}
}