for idx in range(1, 11):
n, string = map(str, input().split())
stack = []
for s in string:
# stack이 비어있지 않고, stack의 마지막 글자와 s와 같다면 중복이므로 pop으로 삭제
if stack and s == stack[-1]:
stack.pop()
# 중복이 아니라면 추가
else:
stack.append(s)
print('#{} {}'.format(idx, ''.join(stack)))
'Algorithm > SW Expert Academy' 카테고리의 다른 글
[Python] 1961. 숫자 배열 회전 (0) | 2021.09.16 |
---|---|
[Python] 1859. 백만장자 프로젝트 (0) | 2021.09.16 |
[Python] 4613. 러시아 국기 같은 깃발 (0) | 2021.09.14 |
[Python] 4873. 반복 문자 지우기 (0) | 2021.09.14 |
[Python] 4871. 그래프 경로 (0) | 2021.09.14 |