Super Reduced String

Sort by

recency

|

1735 Discussions

|

  • + 0 comments

    That’s a really clear explanation of the Reduced String problem! I like how you broke down the logic of repeatedly removing adjacent duplicates until the string can’t be reduced any further — it’s efficient and easy to follow. Using a stack definitely streamlines the process and keeps the solution clean. I was curious though, have you tried testing your code with very large strings or edge cases where almost all characters are the same? It would be interesting to see how it performs in those scenarios. While reading about similar problem-solving techniques, I came across some insightful resources like derma-roller and this one — both highlight how subtle refinements can make a big difference, much like optimizing an algorithm for better efficiency.

  • + 0 comments

    Hey there — that’s a cool discussion about the Reduced String challenge. I like how people are breaking down the logic of removing adjacent matching characters until no more can be removed. Something I’ve noticed helps is visualizing the string operations step by step or drawing it out to avoid mistakes. Speaking of unexpected parallels, I once stumbled on airport limo services while thinking about “shortest paths,” and it reminded me how small decisions (or deletions) can change the route entirely.

    By the way, in your approach, do you use a stack or two-pointer method, and have you found one to be faster or clearer when debugging edge cases?

  • + 0 comments

    FASTEST Solution

    include

    using namespace std;

    char str[101]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> str;
    
    int top = 0, index = 0;
    while(str[++index] != '\0') {
        if(top < 0 || str[index] != str[top]) str[++top] = str[index];
        else --top; 
    }
    
    if(top < 0) { cout << "Empty String" << endl; return 0; }
    str[top + 1] = '\0';
    cout << str << endl; 
    return 0; 
    

    }

  • + 0 comments
    def superReducedString(s):
        # Write your code here
        while re.search(r'([a-z])\1', s):
            s = re.sub(r'([a-z])\1', '', s)
        return 'Empty String' if len(s) == 0 else s
    
  • + 0 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"; }