Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 342 Bytes

151.md

File metadata and controls

27 lines (18 loc) · 342 Bytes

Reverse Words in a String

Description

link


Solution

  • See Code

Code

O(n)

class Solution(object):
    def reverseWords(self, s):
        """
        :type s: str
        :rtype: str
        """
        return ' '.join(s.split()[::-1])