-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path557.py
22 lines (20 loc) · 824 Bytes
/
557.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
__________________________________________________________________________________________________
sample 20 ms submission
class Solution:
def reverseWords(self, s: str) -> str:
return " ".join(word[::-1] for word in s.split())
sentence = ""
for word in s.split():
sentence += word[::-1] + " "
return sentence.strip()
__________________________________________________________________________________________________
sample 13112 kb submission
class Solution:
def reverseWords(self, s: str) -> str:
a_list = s.split()
res = ""
for word in a_list:
word = word[::-1]
res += word + " "
return res[:-1]
__________________________________________________________________________________________________