One line accepted python code, although that is no the interview goal.
class Solution: # @param s, a string # @return a string def reverseWords(self, s): return ' '.join(reversed(s.split()))
Came here to post this exact solution. You beat me to it.
I think java and c++ people would call this cheating, but if I was interviewing somebody for a python job and they resorted to iterating through letters, I'd assume they didn't know Python very well.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.