2021.01.31
CHAPTER12 구현 문제
08 문자열 재정렬
import sys
sys.stdin = open("input.txt", "r")
def getResult(_input):
ret = ''
front = 0
back = len(_input) - 1
if _input[front] >= ord('A') or _input[back] < ord('A'):
return str(map(chr, _input))
while front + 1 < back:
mid = int((front+back)/2)
if _input[mid] >= ord('A'):
back = mid
else:
front = mid
ret += ''.join(list(map(chr, _input[back : len(_input)-1])))
ret += ''.join(list(map(chr, _input[0 : front])))
return ret
input_data = sorted(list(map(ord, input())))
print(getResult(input_data))
Comment