You are viewing a single comment's thread. Return to all comments →
Java 8
public static String superReducedString(String s) { StringBuilder sb = new StringBuilder(s); for(int i=1; i<sb.length(); i++) { if(sb.charAt(i-1) == sb.charAt(i)) { sb.replace(i-1, i+1, ""); i=0; } } s = sb.toString(); 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