Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
Update (2015-02-12):
For C programmers: Try to solve it in-place in O(1) space.
想法很朴素:
1.将单词分出来。
2.类似头插法,将单词插入到新的字符串,就能反过来了。
void reverseWords(string &s) { if (s == "")return; int i = 0; string temp=""; string temp2 = ""; while (s[i]!='