You are viewing a single comment's thread. Return to all comments →
used recursion:
static String super_reduced_string(String string, int startIndex){ if(string.length() == 0) return "Empty String"; else if(string.length() == startIndex + 1) return string; if(string.charAt(startIndex) == string.charAt(startIndex + 1)) { return super_reduced_string(string.substring(0, startIndex) + string.substring(startIndex + 2), --startIndex < 0 ? 0 : startIndex);//avoid negative index } else { return super_reduced_string(string, ++startIndex); } }
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 →
used recursion: