151. Reverse Words in a String
题目:
https://leetcode.com/problems/reverse-words-in-a-string/
难度:
Medium
这对我Python来说,实在太简单,或许我应该看看别的语言的思路和算法
class Solution(object):
def reverseWords(self, s):
"""
:type s: str
:rtype: str
"""
sList = s.split()
sList.reverse()
return " ".join(sList)
网友评论