SHARE
TWEET

Mitchellllll

Blockhead7360 Oct 23rd, 2019 (edited) 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Hello {
  2.  
  3.     public static void main(String[] args) {
  4.         String str = "aaabbccccdddeeeee";
  5.        
  6.         char[] a1 = str.toCharArray();
  7.        
  8.         int parse2 = 1;
  9.         char strk = ' ';
  10.         int len = 0;
  11.        
  12.         while(parse2 < str.length()) {
  13.             int parse3 = parse2;
  14.             char cur = a1[parse3];
  15.            
  16.             int newLen = 0;
  17.            
  18.             if (a1[parse3] == a1[parse3 - 1]) {
  19.                 while (parse3 < str.length() && a1[parse3] == a1[parse3 - 1]) {
  20.                     parse3++;
  21.                     newLen++;
  22.                 }
  23.             }else {
  24.                 parse3++;
  25.             }
  26.            
  27.             if (newLen > len) {
  28.                 len = newLen + 1;
  29.                 strk = cur;
  30.             }
  31.            
  32.             parse2 = parse3;
  33.            
  34.         }
  35.        
  36.         System.out.println(strk + " " + len);
  37.     }
  38.    
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top