You are viewing a single comment's thread. Return to all comments →
My simple C++ solution:
string superReducedString(string &s) { int i = 0; for ( i = 1; ( !s.empty() && i <= s.size() ); i++) { if ( s[i-1] == s[i]) { s.erase((i - 1), 2); i = 0; } } return s = (!s.empty()) ? s: "Empty String"; }
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 simple C++ solution:
string superReducedString(string &s) { int i = 0; for ( i = 1; ( !s.empty() && i <= s.size() ); i++) { if ( s[i-1] == s[i]) { s.erase((i - 1), 2); i = 0; } } return s = (!s.empty()) ? s: "Empty String"; }