思路:
先按空格将字符串转换成数组,然后从数组末尾元素加一个个加进去。
# -*- coding:utf-8 -*-
class Solution:
def ReverseSentence(self, s):
# write code here
arr=s.split(" ")
return " ".join(arr[::-1])
思路:
先按空格将字符串转换成数组,然后从数组末尾元素加一个个加进去。
# -*- coding:utf-8 -*-
class Solution:
def ReverseSentence(self, s):
# write code here
arr=s.split(" ")
return " ".join(arr[::-1])