We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9abc6f3 commit dca47fcCopy full SHA for dca47fc
0151-reverse-words-in-a-string/solution.py
@@ -1,5 +1,9 @@
1
+# Approach 1: Built-in Split + Reverse
2
+
3
+# Time: O(n)
4
+# Space: O(n)
5
6
class Solution:
7
def reverseWords(self, s: str) -> str:
- words = s.split()
- return ' '.join(reversed(words))
8
+ return ' '.join(reversed(s.split()))
9
0 commit comments