Reverse Words in a String III (Leetcode 557)

Problem Link: https://leetcode.com/problems/reverse-words-in-a-string-iii/

class Solution:
    def reverseWords(self, s: str) -> str:
        arr=list(map(str,s.split(' ')))
        ans=''
        for i in arr:
            ans=ans+i[::-1]+' '
        return ans[:len(ans)-1]

Last updated