美文网首页Leetcode
151. Reverse Words in a String

151. Reverse Words in a String

作者: oo上海 | 来源:发表于2016-07-26 05:58 被阅读12次

    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)
            
    

    相关文章

      网友评论

        本文标题:151. Reverse Words in a String

        本文链接:https://www.haomeiwen.com/subject/bornjttx.html