Skip to content

Commit dca47fc

Browse files
committed
Sync LeetCode submission Runtime - 1 ms (42.46%), Memory - 17.9 MB (36.87%)
1 parent 9abc6f3 commit dca47fc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# Approach 1: Built-in Split + Reverse
2+
3+
# Time: O(n)
4+
# Space: O(n)
5+
16
class Solution:
27
def reverseWords(self, s: str) -> str:
3-
words = s.split()
4-
return ' '.join(reversed(words))
8+
return ' '.join(reversed(s.split()))
59

0 commit comments

Comments
 (0)