Skip to content

Commit 0b3e1cd

Browse files
Merge pull request #283 from Coding-Crew-Forever/jiyoung1814/algorithm
[2025년 09월 넷째주 / jiyoung1814] 구현
2 parents 65b42e3 + 5a944aa commit 0b3e1cd

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
def solve(word):
6+
visited = [False] * len(word)
7+
8+
def find_alphabet(start, end):
9+
if start > end:
10+
return
11+
12+
min_idx = min(range(start, end + 1), key=lambda x: word[x])
13+
visited[min_idx] = True
14+
15+
print(''.join(word[i] for i in range(len(word)) if visited[i]))
16+
17+
find_alphabet(min_idx+1, end)
18+
find_alphabet(start,min_idx-1)
19+
20+
21+
find_alphabet(0, len(word)-1)
22+
23+
24+
word = list(input().strip())
25+
solve(word)
26+
27+

0 commit comments

Comments
 (0)