일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- bootstrap #css #CSS
- function #사용자 정의 함수
- 티스토리챌린지
- lvm #lv #vg #pv
- NameSpace #NS
- 백준 #10430
- Excel #엑셀
- 네트워크 #NW
- jgrp000032 #ocp #
- shell #shell script
- 오블완
- OCP
- memory
- Swap Memory
- Grid #CSS
- Node #POD #Container
- Python #pakage
- dump #jattach
- Linux #wc
- test #비교
- dify
- Kafka #카프카
- swap
- PODS #POD #pods #pod #파드 #재기동 #롤링재기동 #rolling
- 스왑메모리
- publishnotreadyaddress
- jmap #jstack
- DB #mariaDB #SQL
- istio #k8s #kubernetes
- CI #CD #CI/CD
Archives
- Today
- Total
beomzh_it
[programmers]python 12917 문자열 내림차순 배치 본문
728x90
반응형
# 문자열 내림차순으로 배치하기
# 문자열 s에 나타나는 문자를 쿤것부터 작은순으로 정렬해 새로운 문자열 리턴
# 문자열을 ascii code로 변환해서 순서를 맞춘 후 다시 정렬
# ord() chr()
# 굳이 변환해서 안풀어도 괜찮네?
def solution(s):
return ''.join(sorted(s,reverse=True))
# answer = []
# ans=''
# for i in s:
# print(i)
# answer.append(ord(i))
# answer.sort()
# answer=reversed(answer)
# for i in answer:
# ans+=(chr(i))
# return ans
print(solution("Zbcdefg")) #"gfedcbZ"
728x90
반응형
'Algorithm > Python' 카테고리의 다른 글
[programmers]python 12940 최소공배수 최대공약수 (0) | 2024.05.31 |
---|---|
[programmers]python 12980 점프와 순간이동 (0) | 2024.05.28 |
약수구하기 (0) | 2024.05.09 |
[programmers]python 12903 가운데 글자 가져오기 (0) | 2024.05.09 |
[programmers] python 77884 약수의 개수와 덧셈 (0) | 2024.05.09 |