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]
PreviousBackspace String Compare (Leetcode 844)NextFind First Palindromic String in the Array (Leetcode 2108)
Last updated