請教一ALGORITHM問題

來源: 曾經滴衰鍋 2009-03-03 22:50:29 [] [舊帖] [給我悄悄話] 本文已被閱讀: 次 (288 bytes)
Someone with deep IT background please help -
Implement an efficient algorithm to reverse a string using java (ie, string "nice to see you!" becomes "you! see to nice"). I did it with StringBuilder and tested it with a string containing as many as 3 million words; it wasn't fast.

所有跟帖: 

回複:請教一ALGORITHM問題 -svm- 給 svm 發送悄悄話 (29 bytes) () 03/03/2009 postreply 23:03:26

I forget about java, but the algorithm seems not hard. -亂彈- 給 亂彈 發送悄悄話 亂彈 的博客首頁 (394 bytes) () 03/03/2009 postreply 23:14:21

嗯,就是你說的算法 -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

回複:請教一ALGORITHM問題 -sub101- 給 sub101 發送悄悄話 (74 bytes) () 03/04/2009 postreply 06:23:58

This definitely works, but uses too much memory. I -亂彈- 給 亂彈 發送悄悄話 亂彈 的博客首頁 (140 bytes) () 03/04/2009 postreply 06:47:32

回複:This definitely works, but uses too much memory. I -sub101- 給 sub101 發送悄悄話 (197 bytes) () 03/04/2009 postreply 08:01:07

My solution: O(n) running time -TuLaLa- 給 TuLaLa 發送悄悄話 (446 bytes) () 03/04/2009 postreply 16:04:52

space O(1), speed O(n) -ncpga- 給 ncpga 發送悄悄話 (75 bytes) () 03/05/2009 postreply 09:30:49

請您先登陸,再發跟帖!

發現Adblock插件

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

關閉Adblock後 請點擊

請參考如何關閉Adblock/Adblock plus

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

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