You are viewing a single comment's thread. Return to all comments →
This is my Java 8 (15) solution using REGEX, feel free to ask me any questions.
public static int alternatingCharacters(String s) { Matcher m = Pattern.compile("([AB])\\1+").matcher(s); return s.length() - m.replaceAll("$1").length(); }
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 →
This is my Java 8 (15) solution using REGEX, feel free to ask me any questions.