Leetcode #151 Reverse Words in a String

题目链接:https://leetcode.com/problems/reverse-words-in-a-string/

 

反转字符串的方法有很多种。要求空间复杂度是常数的话,可以先反转所有的单词,然后反转整个字符串。

例如"the sky is blue",可以先反转为"eht yks si eulb"然后反转整个字符串得到"blue is sky the"。

posted @ 2015-04-06 20:36  meowcherry  阅读(100)  评论(0编辑  收藏  举报