You are viewing a single comment's thread. Return to all comments →
C++ 20:
string onestepReduction (string s){ int n = s.size(); string reduced = ""; int count; for (int i = 0; i < n-1; i++){ if (s[i] != s[i+1]){ reduced += s[i]; count = i; } else{ count = i+1; break; } } for (int j = count+1; j < n; j++) reduced += s[j]; return reduced; } string superReducedString(string s) { string reduced = onestepReduction(s); while (reduced != s && reduced != ""){ s = reduced; reduced = onestepReduction(s); } if (reduced == "") return "Empty String"; else return reduced; }
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 →
C++ 20: