主题:求教大家一个算法问题 -- looklook
共:💬24 🌺10 新:
A hash function (or hash algorithm) is a way of creating a small digital "fingerprint" from "any kind of data".
我同意楼主的意见, 这个问题的正解是不用hash.即使是子衿提到的非整数情况, 也应该不需要用到hash--只要是数字, 还是容易比较的.
如果这个问题继续扩展呢? 找出一个string array中两个相同的; 找出一个object array中两个相同的, 这恐怕就非用hash不可了?
当然, 在实际工作中, 楼下的大虫兄的方法会是我最先想到的.
- 相关回复 上下关系8
🙂Variation of the classic issue. bigbug 字462 2006-05-07 16:12:30
🙂not the most efficient method 小章 字397 2006-05-13 15:06:12
🙂Yes, it's the solution for Microsoft interview question. bigbug 字126 2006-05-20 01:38:24
🙂这恐怕不能称为是一种hash方法
🙂这个我也想过的,但是这个方法只限于整数 1 【子衿】 字108 2006-05-05 23:36:53
🙂的确,浮点数的情况比较麻烦,可能还是先排序快... 燕归来 字38 2006-05-06 09:57:52
🙂Use Hashset. 1 bigbug 字22 2006-05-05 12:23:29
🙂这是个algorithm问题,不能这样解决 looklook 字343 2006-05-05 12:44:43