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

來源: 亂彈 2009-03-03 23:14:21 [] [博客] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (394 bytes)
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

請您先登陸,再發跟帖!

發現Adblock插件

如要繼續瀏覽
請支持本站 請務必在本站關閉/移除任何Adblock

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

安裝Adblock plus用戶請點擊瀏覽器圖標
選擇“Disable on www.wenxuecity.com”

安裝Adblock用戶請點擊圖標
選擇“don't run on pages on this domain”