You are viewing a single comment's thread. Return to all comments →
Java 8, Using regular expressions. Please use regex101.com for explanation of the regex.
public static String superReducedString(String s) { String REGEX = "([a-z])\\1"; String REGEX_FULL = String.format(".*%s.*", REGEX); while (s.matches(REGEX_FULL)) { s = s.replaceAll(REGEX, ""); } return s.isEmpty() ? "Empty String" : s; }
Seems like cookies are disabled on this browser, please enable them to open this website
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
Java 8, Using regular expressions. Please use regex101.com for explanation of the regex.