Super Reduced String

  • + 0 comments

    C++ Trick is to use a stack, but can just use a string the same way. Moving from left to right, if the current char is the same as on the top of stack (or .back() of string) pop it (pop_back()), and do not push it to stack, effectivly deleting them. Else we push character to the stack (push_back()). If we use a string as a stack, we can just return this resulting string;