Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int maxBlock(String str) {
- int max = 0;
- for(int i = 0; i < str.length(); i++)
- {
- char c = str.charAt(i);
- int j = i + 1;
- int possibleMax = 1;
- // iterate through a "block"
- while(j < str.length() && str.charAt(j) == c)
- {
- possibleMax++;
- j++;
- }
- // if the block's length is greater than any found, save it
- if(possibleMax > max)
- max = possibleMax;
- }
- return max;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement