Python solution


  • 0
    D
    
    
    class Solution(object):
        def reverseWords(self, s):
            """
            :type s: str
            :rtype: str
            """
            r = s.strip().split()[::-1]
            return " ".join(r)
    
    def main():
        obj = Solution()
        print obj.reverseWords("the sky is blue")
    
    if __name__ == "__main__":
        main()
    
    

Log in to reply
 

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