I forget about java, but the algorithm seems not hard.

I suppose the word separator is a space. One algorithm is like this:

(1) Reverse the string char by char. This is easy.
(2) Reverse each word. You need to find the start and end positions of each word.

This algorithm scans the string twice, and should be fast enough.

It is possible to scan the string only once, but the algorithm sounds more complicated to me.

所有跟帖: 

嗯,就是你說的算法 -svm- 給 svm 發送悄悄話 (39 bytes) () 03/03/2009 postreply 23:19:12

you may think it's silly, it's fast -interested1- 給 interested1 發送悄悄話 (141 bytes) () 03/04/2009 postreply 21:56:38

回複:I forget about java, but the algorithm seems not hard. -sub101- 給 sub101 發送悄悄話 (48 bytes) () 03/04/2009 postreply 06:25:19

請您先登陸,再發跟帖!