题解 | #点击消除#
点击消除
https://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5
def optimize_delete(s): stack = [] for char in s: if not stack or stack[-1] != char: stack.append(char) else: stack.pop() return '0' if not stack else ''.join(stack) s = input() print(optimize_delete(s))