r/javahelp • u/N64gamefreak • Sep 05 '20
Need Help with Popping Blocks Program
public class Challenge {
public static char\[\] finalResult(char\[\] letters) {
StringBuilder sb = new StringBuilder(new String(letters));
public static int getRepeatingCharIndex(String str) {
for (int i=0; i<str.length()-1; i++) {if (str.charAt(i) == str.charAt(i+1))
return i;
}
return -1;
}
int index = getRepeatingCharIndex(sb.toString());
while (index != -1) {
int end = index;
while (end < sb.length() && sb.charAt(end) == sb.charAt(index))end++;
sb.delete(index, end);
index = getRepeatingCharIndex(sb.toString());
}
return sb.toString().toCharArray();
}}
0
Upvotes
2
u/-themailerdoraemon- Sep 05 '20
AND? What is the question? You can't just post unreadable and unformatted code here without writing what you need help with!