题解 | #点击消除#

点击消除

https://www.nowcoder.com/practice/8d3643ec29654cf8908b5cf3a0479fd5

import sys

str=input()

list1=[]
for char in str:
    if len(list1)==0:
        list1.append(char)
    elif len(list1)>=1 and list1[-1]!=char:
        list1.append(char)
    elif len(list1)>=1 and list1[-1]==char:
        list1.pop()
if len(list1)==0:
    print(0)
else:
    print(''.join(list1))                    

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务