LeetCode--Reverse Words in a String

 1 class Solution:
 2     # @param s, a string
 3     # @return a string
 4     def reverseWords(self, s):
 5         s = s.rstrip().lstrip()
 6         d = s.split(' ')
 7         e = d[::-1]
 8         f = " ".join(e)
 9         f = " ".join(f.split())
10         return f

 

posted @ 2014-03-22 22:06  laste  阅读(94)  评论(0编辑  收藏  举报