You are viewing a single comment's thread. Return to all comments →
My Java 8 Solution
public static String superReducedString(String s) { StringBuilder reducedString = new StringBuilder(); for (char c : s.toCharArray()) { int length = reducedString.length(); if (length > 0 && reducedString.charAt(length - 1) == c) { reducedString.deleteCharAt(length - 1); } else { reducedString.append(c); } } return reducedString.length() == 0 ? "Empty String" : reducedString.toString(); }
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 →
My Java 8 Solution