a similar but harder problem

来源: dynamic 2009-05-18 09:43:31 [] [旧帖] [给我悄悄话] 本文已被阅读: 次 (122 bytes)
本文内容已被 [ dynamic ] 在 2009-06-09 09:31:02 编辑过。如有问题,请报告版主或论坛管理删除.
一个数组有n+1个数,都在1到n之间,并且每个数至少出现一次(有一个数重复了),找出那个重复的数(只能用constant memory)。

所有跟帖: 

sum mod n -haha2000- 给 haha2000 发送悄悄话 (0 bytes) () 05/18/2009 postreply 09:52:57

I asked a similar question in an interview. -乱弹- 给 乱弹 发送悄悄话 乱弹 的博客首页 (162 bytes) () 05/18/2009 postreply 10:01:54

you are definitely right... I need to fix it :) -dynamic- 给 dynamic 发送悄悄话 (0 bytes) () 05/18/2009 postreply 10:48:03

fix of the problem -dynamic- 给 dynamic 发送悄悄话 (160 bytes) () 05/18/2009 postreply 10:51:26

algorithmic complexity requirement? -haha2000- 给 haha2000 发送悄悄话 (103 bytes) () 05/18/2009 postreply 19:19:21

can be done in linear time... -haha2000- 给 haha2000 发送悄悄话 (150 bytes) () 05/18/2009 postreply 19:42:41

it takes a bit more than that -dynamic- 给 dynamic 发送悄悄话 (438 bytes) () 05/18/2009 postreply 19:55:29

hmm,这个有意思:) -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (0 bytes) () 05/18/2009 postreply 21:12:19

回复:it takes a bit more than that -utopian- 给 utopian 发送悄悄话 (51 bytes) () 05/20/2009 postreply 17:23:11

hashing needs linear memory as well. we want constant memory her -dynamic- 给 dynamic 发送悄悄话 (0 bytes) () 05/20/2009 postreply 17:28:12

Pay attention to some key numbers. -乱弹- 给 乱弹 发送悄悄话 乱弹 的博客首页 (0 bytes) () 05/20/2009 postreply 19:24:24

觉得在哪里见过这个题目 -haha2000- 给 haha2000 发送悄悄话 (19 bytes) () 05/21/2009 postreply 07:24:10

I don't think so. -乱弹- 给 乱弹 发送悄悄话 乱弹 的博客首页 (0 bytes) () 05/21/2009 postreply 09:52:29

这题目是IMB 2004 一月的一个puzzle:) -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (79 bytes) () 05/21/2009 postreply 12:22:12

Yes, right! thanks! -haha2000- 给 haha2000 发送悄悄话 (0 bytes) () 05/22/2009 postreply 11:05:23

solution -dynamic- 给 dynamic 发送悄悄话 (572 bytes) () 05/20/2009 postreply 21:41:18

hmmm,佩服. "形状像一个勺子", haha... -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (0 bytes) () 05/21/2009 postreply 12:25:03

这个题目曾是微软的面试题目。但是没有了数组'read only'的条件, -戏雨飞鹰- 给 戏雨飞鹰 发送悄悄话 戏雨飞鹰 的博客首页 (75 bytes) () 05/21/2009 postreply 13:12:13

请您先登陆,再发跟帖!

发现Adblock插件

如要继续浏览
请支持本站 请务必在本站关闭/移除任何Adblock

关闭Adblock后 请点击

请参考如何关闭Adblock/Adblock plus

安装Adblock plus用户请点击浏览器图标
选择“Disable on www.wenxuecity.com”

安装Adblock用户请点击图标
选择“don't run on pages on this domain”