def sol(s):
len_s = len(s)
strings = []
for i in range(1, len_s - 1):
for j in range(1, len_s - 1):
if i + j <= len_s - 1:
strings.append(s[:i][::-1] + s[i:i + j][::-1] + s[i + j:][::-1])
return(sorted(strings)[0])
s=input()
print(sol(s))
https://www.acmicpc.net/problem/2993
1251번 문제와 같음
Same with #1251 problem
반응형
'python-algorithm' 카테고리의 다른 글
프로그래머스 중복된 숫자 개수 (0) | 2022.10.19 |
---|---|
프로그래머스 배열의 평균값 (0) | 2022.10.19 |
백준 2535 아시아 정보올림피아드 (0) | 2022.10.18 |
백준 20124 모르고리즘 회장님 추천 받습니다 (0) | 2022.10.17 |
백준 23278 영화 평가 (0) | 2022.10.17 |
댓글