import sys
for _ in range(int(input())):
left = []
right = []
input = sys.stdin.readline()
for c in input :
if c == "<":
if left :
right.append(left.pop())
elif c == ">":
if right :
left.append(right.pop())
elif c == "-":
if left :
left.pop()
else :
left.append(c)
left.extend(right)
print("".join(list(left)))
'leetcode 풀이 > 큐, 스택 (Array)' 카테고리의 다른 글
boj-7785. 회사에있는사람 (0) | 2023.01.20 |
---|---|
boj-2164. 카드 2 (0) | 2023.01.19 |
boj-11866. 요세푸스 문제 (0) | 2023.01.19 |
leetcode 46. Permutations 순열 (0) | 2022.04.03 |
leetcode 153 - Find Minimum in Rotated Sorted Array (0) | 2022.03.28 |
댓글