4 lines python, ac 41ms


  • 0
    Y
    class Solution(object):
        def reverseWords(self, s):
            """
            :type s: str
            :rtype: str
            """
            if s!=None:
                
                s=s.split()
                s=s[::-1]
                return " ".join(s)

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.