Super Reduced String

  • + 0 comments

    def superReducedString(s): stack = [] for n in s: if not stack or stack[-1] != n: stack.append(n) else: stack.pop() if not stack: return 'Empty String' return "".join(stack)