You are viewing a single comment's thread. Return to all comments →
Java:
public static int alternatingCharacters(String s) { int deletions = 0; for (int i = 0; i < s.length() - 1; i++) { if (s.charAt(i) == s.charAt(i + 1)) { deletions++; } } return deletions; }
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 →
Java: