1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Solution:
def sortSentence(self, s: str) -> str:
tmp=list(map(str, s.split()))
ans=[0]*len(tmp)
nums="0123456789"
for i in range (len(tmp)):
for j in nums:
if j in tmp[i]:
tmp1=tmp[i].replace(j,"")
ans[int(j)-1]=tmp1
ansStr=ans[0]
for i in range(1,len(ans)):
ansStr=ansStr+" "+ans[i]
return ansStr
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
Leetcode 1323. Maximum 69 Number (0) | 2021.07.21 |
---|---|
백준 2864 5와 6의 차이 (0) | 2021.07.20 |
백준 3029 경고 (0) | 2021.07.16 |
Leetcode 1913. Maximum Product Difference Between Two Pairs (0) | 2021.07.16 |
Leetcode 1486. XOR Operation in an Array (0) | 2021.07.16 |
댓글