Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 592 Bytes

151._reverse_words_in_a_string.md

File metadata and controls

37 lines (29 loc) · 592 Bytes

151. Reverse Words in a String

题目: https://leetcode.com/problems/reverse-words-in-a-string/

难度: Medium

太简单了

class Solution(object):
    def reverseWords(self, s):
        """
        :type s: str
        :rtype: str
        """
        tmp = s.split()
        res = " ".join(tmp[::-1])
        return res
        
class Solution(object):
    def reverseWords(self, s):
        """
        :type s: str
        :rtype: str
        """
        tmp = s.split()
        tmp.reverse()
        res = " ".join(tmp)
        return res