Python3代码:
class Solution:
def reverseWords(self, s: str) -> str:
# ans = []
# for ss in s.split(' '):
# ans.append(ss[::-1])
# return ' '.join(ans)
# return ' '.join(item[::-1] for item in s.split(' '))
return ' '.join(s.split(' ')[::-1])[::-1]
网友评论