Skip to content

Commit 18eb819

Browse files
committed
[BOJ] #13417. 카드 문자열 / 실버3 / 30분 / 성공
1 parent a6db44f commit 18eb819

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import sys
2+
from collections import deque
3+
input = sys.stdin.readline
4+
5+
t = int(input())
6+
for _ in range(t):
7+
n = int(input()) # 거스름돈 액수
8+
alphabet = list(map(str, input().split()))
9+
alphabet = deque(alphabet)
10+
answer = alphabet.popleft() # 정답 문자열
11+
12+
while alphabet:
13+
current = alphabet.popleft()
14+
if current <= answer[0]: # 가장 앞의 문자와 비교. 더 앞에 있다면 가장 왼쪽에 붙이기
15+
answer = current + answer
16+
else:
17+
# 뒤에 있다면 가장 오른쪽에 붙이기
18+
answer += current
19+
20+
print(answer)

0 commit comments

Comments
 (0)