主题:求教大家一个算法问题 -- looklook
you sure this is the solution for msft interview question?
if the sequence is continuous (but one missing/duplicating) and bounded, the solution is to take the summation and then get the one missing/duplicating by comparing with the summation of the whole continuous sequence. (actually, i guess one more function, e.g. summation of squres is needed to find the duplicating/missing couple).
- 相关回复 上下关系8
压缩 2 层
🙂這不是pigeon hole sorting的算法嗎:) 1 wildpig 字0 2006-05-06 02:37:29
🙂这是个经典题目, 答案的确如此。原题是这样的: 1 萝卜酒 字122 2006-05-06 01:11:16
🙂Variation of the classic issue. bigbug 字462 2006-05-07 16:12:30
🙂not the most efficient method
🙂Yes, it's the solution for Microsoft interview question. bigbug 字126 2006-05-20 01:38:24
🙂这恐怕不能称为是一种hash方法 2 aniu 字418 2006-05-06 00:46:43
🙂这个我也想过的,但是这个方法只限于整数 1 【子衿】 字108 2006-05-05 23:36:53
🙂的确,浮点数的情况比较麻烦,可能还是先排序快... 燕归来 字38 2006-05-06 09:57:52