7/19/2020

[LeetCode] 151. Reverse Words in a String

Problem : https://leetcode.com/problems/reverse-words-in-a-string/
A lazy solution:

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

No comments:

Post a Comment