# @param s, a string
# @return a string
def reverseWords(self, s):
return " ".join(s.split()[::-1])
Yes, utilizing the built-in methods of string can reduce the volume of the code heavily.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.