Super Reduced String

  • + 0 comments
    def superReducedString(s):
        out = ''
        for value in s:
            if '' == out or value != out[-1]:
                out += value
            else:
                out = out[:-1]
        return out if '' != out else 'Empty String'