Python solution ~ 44ms

  • 0

    Please find my solution here:

    class Solution(object):
        def reverseWords(self, s):
            :type s: str
            :rtype: str
            s = s.strip().
            s_list = s.split(' ')
            out_list = []
            for s_item in s_list:
              if s_item:
            return ' '.join(out_list[::-1])

Log in to reply

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