Python 3 lines 40ms solution


  • 4
    H
    class Solution(object):
        def reverseWords(self, s):
            """
            :type s: str
            :rtype: str
            """
            s=s.strip()
            sl=s.split()
            return ' '.join(reversed(sl))

Log in to reply
 

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