Leetcode

151. Reverse Words in a String

2016-07-26  本文已影响12人  oo上海

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)
        
上一篇下一篇

猜你喜欢

热点阅读