You are viewing a single comment's thread. Return to all comments →
public static int alternatingCharacters(String str) { int firstptr=0; int secondptr = firstptr+1; int totaldeletions = 0; while(secondptr < str.length()) { if(str.charAt(firstptr) == str.charAt(secondptr)) { totaldeletions++; secondptr++; } else { firstptr = secondptr; secondptr++; } } return totaldeletions; }
Seems like cookies are disabled on this browser, please enable them to open this website
Alternating Characters
You are viewing a single comment's thread. Return to all comments →