T-coding
백준 5397 키로거 / Python 본문
728x90
728x90
https://www.acmicpc.net/problem/5397
코드
더보기
t = int(input())
for _ in range(t):
s = list(input())
left, right = [], []
for i in s:
if i == '<':
if left:
right.append(left.pop())
elif i == '>':
if right:
left.append(right.pop())
elif i == '-':
if left:
left.pop()
else:
left.append(i)
left.extend(reversed(right))
print(''.join(left))
728x90
300x250
'Baekjoon' 카테고리의 다른 글
백준 14503 로봇 청소기 / Python (0) | 2023.03.21 |
---|---|
백준 5567 결혼식 / Python (0) | 2023.03.21 |
백준 4198 열차정렬 / Python (0) | 2023.03.20 |
백준 3186 소변기 / Python (0) | 2023.03.20 |
백준 14467 소가 길을 건너간 이유 1 (0) | 2023.03.19 |