由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 算法题:两列找共同元素有O(n)的算法吗?
相关主题
请教个面试题攒人品,twitter二面面经
Google电话面试题目Given an int array and an int value. Find all pairs in arr
请教一个问题的答案,好像以前有人讨论过求教一个onsite面试题目
CS: print all combination from an arrayebay90%的老印不会算法 湾区至少70%以上的老印不会算法
面试题求解:remove first duplicate number from an array一道老题
问一个面试题careercup上这道题我竟然没看懂
一道算法题a[i] + b[j] = c[k] 的题有靠谱的答案不?
O(N) sort integer arrayamazon 电面问题 求解答, 在线等
相关话题的讨论汇总
话题: 算法话题: what话题: array话题: duplicates话题: arrays
进入JobHunting版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
Given two arrays, each with distinct integers, give an efficient
algorithm to find out the common elements.
显然我们可以对两个数列进行快速排序。但有更简单的算法吗?
C***y
发帖数: 2546
2
hash

【在 c**********e 的大作中提到】
: Given two arrays, each with distinct integers, give an efficient
: algorithm to find out the common elements.
: 显然我们可以对两个数列进行快速排序。但有更简单的算法吗?

P**l
发帖数: 3722
3
hash
a*****a
发帖数: 46
4
What if the arrays are huge?
We can use bitset for hash to save space but then what if there are
duplicates in each array?
We can not use one bit to represent a number since it may have duplicates.
What to do?
Thanks.
A*H
发帖数: 127
5
of course you can, when you see duplicates in first array, just don't do
anything, when you see dup in second array, it's a common number

【在 a*****a 的大作中提到】
: What if the arrays are huge?
: We can use bitset for hash to save space but then what if there are
: duplicates in each array?
: We can not use one bit to represent a number since it may have duplicates.
: What to do?
: Thanks.

f****4
发帖数: 1359
6
如果数据没多到内存里放不下hash信息的话,用hashmap就能处理重复
(key, value)扫描A的术后,第一次插入(key, 1)有重复的话,对++value
B扫描,--value,直到0,都是重复的
如果内存放不下hash信息了,只能用mergsort,对2个array进行外部排序
然后从2个array里面取同等大小数据段,扫描,直到任意array空

【在 a*****a 的大作中提到】
: What if the arrays are huge?
: We can use bitset for hash to save space but then what if there are
: duplicates in each array?
: We can not use one bit to represent a number since it may have duplicates.
: What to do?
: Thanks.

1 (共1页)
进入JobHunting版参与讨论
相关主题
amazon 电面问题 求解答, 在线等面试题求解:remove first duplicate number from an array
求这道题的O(N)解 (转载)问一个面试题
也问一个算法题一道算法题
[合集] Google电话面试题目O(N) sort integer array
请教个面试题攒人品,twitter二面面经
Google电话面试题目Given an int array and an int value. Find all pairs in arr
请教一个问题的答案,好像以前有人讨论过求教一个onsite面试题目
CS: print all combination from an arrayebay90%的老印不会算法 湾区至少70%以上的老印不会算法
相关话题的讨论汇总
话题: 算法话题: what话题: array话题: duplicates话题: arrays