题解 | 吐泡泡
吐泡泡
https://www.nowcoder.com/practice/f86fa2221c094b3d8d1fc79bae450d96
def rest(s):
l = []
for i in s:
while l :
if l[-1] == 'o' and i == 'o':
l.pop()
i = 'O'
elif l[-1] == 'O' and i == 'O':
l.pop()
i = None
break
else:
break
if i is not None:
l.append(i)
return l
t = int(input())
for i in range(t):
s = input().strip()
result = rest(s)
print(''.join(result))
查看21道真题和解析