Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Testing {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String input = sc.nextLine();
- char[] arrOfInput = input.toCharArray();
- int length = 1;
- int start = 0;
- int bestlength=0;
- int beststart=0;
- for (int i = 1; i < arrOfInput.length; i++)
- {
- if (arrOfInput[i - 1] == arrOfInput[i])
- {
- length++;
- continue;
- }
- if (bestlength<length)
- {
- bestlength = length;
- beststart = start;
- }
- length = 1;
- start = i;
- }
- for (int j = beststart; j < bestlength + beststart; j++)
- {
- System.out.print(arrOfInput[j]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement