3 line solution with Python


  • 0
    H

    def reverseWords(s):
    """
    :type s: str
    :rtype: str
    """
    strArr=s.split()
    strArr.reverse()
    print(strArr)
    return ' '.join(strArr)


Log in to reply
 

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