Leetcode 557 Reverse Words in a String III
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Input: s = "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"
Input: s = "God Ding"
Output: "doG gniD"
- Soruda bize bir string veriliyor ve bu stringin boşluklarla ayrılan kelimelerini ters çevirmemiz isteniyor.
class Solution:
def reverseWords(self, s: str) -> str:
a = s.split(" ")
for i in range(len(a)):
a[i] = a[i][::-1]
return " ".join(a)