목록비밀번호 (1)
1seul357
[SWEA] 비밀번호
T = 10 for TC in range(T): str1, str2 = input().split() stack = [] for i in range(1): stack.append(str2[0]) for j in range(1, len(str2)): if len(stack) > 0: pop = stack[-1] if pop == str2[j]: stack.pop(-1) else: stack.append(str2[j]) else: stack.append(str2[j]) print('#{} '.format(TC+1), end = '') for i in stack: print(i, end = '') print()
알고리즘/SWEA
2021. 12. 3. 13:34