Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LongestBlockInString {
- public static void main(String[] args){
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- // System.out.print(input.length());
- int maxCount = 0;
- char maxSequentChar = ' ';
- int count = 1;
- if(input.length() <= 1){
- System.out.println(input);
- }
- for (int i = 0; i < input.length() - 1; i++){
- if(input.charAt(i) == input.charAt(i + 1)){
- count++;
- }else {
- count = 1;
- }
- if(count > maxCount){
- maxCount = count;
- maxSequentChar = input.charAt(i);
- }
- }
- for(int i = 0; i < maxCount; i++){
- System.out.print(maxSequentChar);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement