557. Reverse Words in a String III
Easy
Input: s = "Let's take LeetCode contest"
Output:
"s'teL ekat edoCteeL tsetnoc"Input: s = "God Ding"
Output:
"doG gniD"class Solution:
def reverseWords(self, s: str) -> str:
result = ""
for word in s.split(" "):
result += word[::-1] + " "
return result.strip()Last updated