3 line solution with Python

  • 0

    Split the line and reverse the order of the resulting array of words, then join the array of words using space.

    class Solution(object):
        def reverseWords(self, s):
            :type s: str
            :rtype: str
            " ".join(arr)

Log in to reply

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