You are viewing a single comment's thread. Return to all comments →
C++ code solution
string superReducedString(string s) { string result; LOOP: string ns; ns.clear(); ns.shrink_to_fit(); bool flag = false; int i = 0; while(i < s.length()){ if (s[i] == s[i+1]){i= i + 2; flag = true;} else {ns.push_back(s[i]);i = i + 1; } } if (flag == true) {s.clear(); s.shrink_to_fit(); s = ns; goto LOOP;} if (ns.length() > 0){result = ns;} else {result = "Empty String";} return result; }
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++ code solution