Skip to content

Commit 3439f5d

Browse files
authored
Merge pull request billryan#101 from shincfk/patch-1
Update reverse_words_in_a_string.md
2 parents 1c49b08 + ab2f35c commit 3439f5d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

zh-hans/string/reverse_words_in_a_string.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,16 @@ public:
8383
2. 处理多个空格及首尾空格
8484
3. 记住单词的头尾指针,翻转之
8585
4. 整体翻转
86+
87+
88+
###Python
89+
```python
90+
91+
class Solution:
92+
# @param s : A string
93+
# @return : A string
94+
def reverseWords(self,s):
95+
# write your code here
96+
return ' '.join(reversed(s.strip().split()))
97+
98+
```

0 commit comments

Comments
 (0)