由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 考古到一道题
相关主题
F家电面:group Anagrams一道面试题的优化
A家面试题学CS的人都是神人吗?这种题目没见过怎么能想出解法
有A[i]re: 面试归来,上面经回馈各位战友
算法题问个amazon面试题
A facebook interview question说说4sum的复杂度吧
书上关于search和sorting的部分 应该不用全看吧?O(N) sort integer array
unordered_set是怎么实现的?问两道amazon的面试题
求问Jane Street一道面试题找2个sorted array中的第K小的元素,有O(lgn)方法吗?
相关话题的讨论汇总
话题: sort话题: bucket话题: radix话题: 不对话题: count
进入JobHunting版参与讨论
1 (共1页)
r**u
发帖数: 1567
1
一个数组中存放N个整数,如何找到出现次数最多的一个数(即众数),要求用O(N)的
复杂度,而且不能用Hashing(内存和时间都是O(N))。
Any new thoughts?
m*****f
发帖数: 1243
2
内存O(N)???
Do you mean O(1)?
If has O(n) memory, count sort, bucket sort, radix sort all can do it ba.
r**u
发帖数: 1567
3
O(N)。你这个不对吧,count sort要知道range,这个range可以是0-2^31-1。不是O(N)。bucket也不对吧。
radix我明白了,对的。

【在 m*****f 的大作中提到】
: 内存O(N)???
: Do you mean O(1)?
: If has O(n) memory, count sort, bucket sort, radix sort all can do it ba.

r********g
发帖数: 1351
4
不好意思我google了一下,发现这道题很trick,因为在实际运算中很难handle x^y这
种运算吧,很容易溢出?
这里假设数组的值都比较小的情况下,然后遍历一遍把数组的信息记录在一个大的数里
。比如,一个弱智的方法是,比如所有的数字都小于10,可以记录在一个digit里,然后
用一个N位数记录每个数字出现的次数。
如果数值不局限于0-9,可以用SUM_i(N^a[i])

N)

【在 r**u 的大作中提到】
: O(N)。你这个不对吧,count sort要知道range,这个range可以是0-2^31-1。不是O(N)。bucket也不对吧。
: radix我明白了,对的。

m*****f
发帖数: 1243
5
You assume these conditions...
I am just saying these methods are O(N), use what depends on communication
with the interviewer..isn't it?

N)。bucket也不对吧。

【在 r**u 的大作中提到】
: O(N)。你这个不对吧,count sort要知道range,这个range可以是0-2^31-1。不是O(N)。bucket也不对吧。
: radix我明白了,对的。

H*M
发帖数: 1268
6
I guess the original question is that the time that number appears is more t
han N/2. If that is the case, yeah, you can solve it in o(N).

【在 r**u 的大作中提到】
: 一个数组中存放N个整数,如何找到出现次数最多的一个数(即众数),要求用O(N)的
: 复杂度,而且不能用Hashing(内存和时间都是O(N))。
: Any new thoughts?

c*****o
发帖数: 178
7
被问到,要求不可以用extra space,但是没有复杂度限制,我就说quick sort O(nlgn)
.然后考官说你知道big O?你哪里学的?汗,对我这非cs的期待好低。。。。。。
r**u
发帖数: 1567
8
That is a different question!
mudhoof说的radix sort solution是对的吧?did I miss something? 不过我觉得count/bucket sort不对。

t

【在 H*M 的大作中提到】
: I guess the original question is that the time that number appears is more t
: han N/2. If that is the case, yeah, you can solve it in o(N).

H*M
发帖数: 1268
9
practically radixsort的efficiency并不好吧
const太大

count/bucket sort不对。

【在 r**u 的大作中提到】
: That is a different question!
: mudhoof说的radix sort solution是对的吧?did I miss something? 不过我觉得count/bucket sort不对。
:
: t

1 (共1页)
进入JobHunting版参与讨论
相关主题
找2个sorted array中的第K小的元素,有O(lgn)方法吗?A facebook interview question
T家一面书上关于search和sorting的部分 应该不用全看吧?
median of two sorted arrays的时间复杂度(附上了过了oj的代码)unordered_set是怎么实现的?
一道 纽约 Morgan Stanley IT Equity Trading 面试题求问Jane Street一道面试题
F家电面:group Anagrams一道面试题的优化
A家面试题学CS的人都是神人吗?这种题目没见过怎么能想出解法
有A[i]re: 面试归来,上面经回馈各位战友
算法题问个amazon面试题
相关话题的讨论汇总
话题: sort话题: bucket话题: radix话题: 不对话题: count