python-algorithm
백준 25773 Number Maximization
무적김두칠
2022. 12. 8. 11:39
https://www.acmicpc.net/problem/25773
25773번: Number Maximization
There is only one input line; it contains an integer between 0 and 999,999 (inclusive). Assume that the input number will not have leading 0’s. Note, however, that the input can be just the value 0.
www.acmicpc.net
1
2
3
4
5
6
7
|
def sol(s):
answer = ''.join(sorted(s,reverse=True))
return answer
if __name__ == '__main__':
s = input()
print(sol(s))
|
cs |
sorted 함수(with reverse)를 통해 숫자를 큰 순서대로 정렬하고
join 함수로 리스트에서 문자열로 만들어 return합니다.
Sort the numbers descendingly using sorted function with reverse
and Type cast list to string with join function
반응형