๋ฌธ์
https://www.acmicpc.net/problem/5397
ํ์ด
# ๋ฐฑ์ค 5397๋ฒ ๋ฌธ์ - ํค๋ก๊ฑฐ
n = int(input())
l = []
for _ in range(n):
l.append(list(input()))
for i in range(n):
stack_l = []
stack_r = []
for cmd in l[i]:
if cmd == '<':
if stack_l:
stack_r.append(stack_l.pop())
elif cmd == '>':
if stack_r:
stack_l.append(stack_r.pop())
elif cmd == '-':
if stack_l:
stack_l.pop()
else:
stack_l.append(cmd)
print(''.join(stack_l + list(reversed(stack_r))))
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold4] 17298๋ฒ_์คํฐ์ (1) | 2023.03.15 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 2493๋ฒ_ํ (0) | 2023.03.13 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 1717๋ฒ_์งํฉ์ ํํ (0) | 2023.03.10 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver2] 1406๋ฒ_์๋ํฐ (0) | 2023.03.09 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver2] 1699๋ฒ_์ ๊ณฑ์์ ํฉ (0) | 2023.03.05 |