You are viewing a single comment's thread. Return to all comments →
Best and performant approach in C++. Behold my simple C++ solution -
string superReducedString(string s) { int i=1; while (i<s.length()) { if (s[i] == s[i-1]) { s.erase(i-1,2); i=1; } else { i++; } } if (s.empty()) { return "Empty String"; } else { return s; } }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Super Reduced String
You are viewing a single comment's thread. Return to all comments →
Best and performant approach in C++. Behold my simple C++ solution -