Flip Each Word
Sometimes you need to change the inside of each word without changing the order of the sentence. Given a string s where words are separated by single spaces, reverse the letters of every word. Keep the word order and spaces the same.
Примеры
Ввод
"Let's take LeetCode contest"Вывод
"s'teL ekat edoCteeL tsetnoc"Ввод
"God Ding"Вывод
"doG gniD"Ввод
"abc"Вывод
"cba"Нужно реализовать
def reverse_words(s: str) -> str:
Теги
strings
Prisijunkite, kad matytumėte pateikimų istoriją
PrisijungtiPrisijunkite, kad naudotumėte DI mentorių
PrisijungtiVisible tests
1
Input
"Let's take LeetCode contest"Expected
"s'teL ekat edoCteeL tsetnoc"2
Input
"God Ding"Expected
"doG gniD"3
Input
"abc"Expected
"cba"4
Input
"a b c"Expected
"a b c"5
Input
"hello"Expected
"olleh"6
Input
" "Expected
" "Focus radio
Paused · SomaFM · Fluid