搜索此博客

2011年2月26日星期六

Reverse words in sentence while keeping position of white space

Input: “I am a student."
Output: “student. a am I"
Time: O(n).

Solution: At the first step, reverse the whole sentence, then reverse the word one by one.

没有评论:

发表评论