[LeetCode] 1859. Sorting the Sentence
Python
class Solution:
def sortSentence(self, s: str) -> str:
answer = ''
temp = s.split()
word = {}
for i in temp:
word[i[-1]]= i[:-1]
for i in sorted(word):
answer = answer+''.join(word[i])+' '
return answer[:-1]
댓글남기기