请教一ALGORITHM问题

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

请您先登陆,再发跟帖!