由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问道题
相关主题
请教一个面试题T problem
Facebook Puzzle Gattaca一个NxN矩阵每行每列都sort好,如何排序?
再问一道题一个特别的inplace merge two sorted arrays
问一个CareerCup上的题数组中找和为0的3个数,4个数
再来问题lint code 这个counter numbers smaller than me
A家面试题google phone interview question
书上关于search和sorting的部分 应该不用全看吧?问个经典问题的improvement
问几道面试题问两道微软题
相关话题的讨论汇总
话题: sort话题: radix话题: repeat话题: binary话题: times
进入JobHunting版参与讨论
1 (共1页)
a**********2
发帖数: 340
1
Given an array of integers where some numbers repeat 1 time, some numbers
repeat 2 times and only one number repeats 3 times, how do you find the
number that repeat 3 times. Using hash was not allowed
有什么巧解吗?
c****p
发帖数: 6474
2
integer的值哉有什么限定么

【在 a**********2 的大作中提到】
: Given an array of integers where some numbers repeat 1 time, some numbers
: repeat 2 times and only one number repeats 3 times, how do you find the
: number that repeat 3 times. Using hash was not allowed
: 有什么巧解吗?

c****p
发帖数: 6474
3
值域。。。

【在 c****p 的大作中提到】
: integer的值哉有什么限定么
a**********2
发帖数: 340
4
32位吧

【在 c****p 的大作中提到】
: integer的值哉有什么限定么
a**********2
发帖数: 340
5
没有人解答一下吗?难道要用sort?
f*******t
发帖数: 7549
6
今天我面A家,三哥问了我这道题。
不过一开始是只有一个数出现奇数次,其它出现偶数次,我就说用异或解决。
然后他又换了个条件,一个数出现偶数次,其它出现奇数次,其实这个网上有用异或解
的代码,我一时实在找不出来,没看懂+记不住。提到hash他又说不能用,最终说了一
个暴力解法一个sort解法,他说sort就是想要的。
v***a
发帖数: 365
7

Sort 不就行了,integer 有好几个O(N)的sort吧

【在 a**********2 的大作中提到】
: Given an array of integers where some numbers repeat 1 time, some numbers
: repeat 2 times and only one number repeats 3 times, how do you find the
: number that repeat 3 times. Using hash was not allowed
: 有什么巧解吗?

v********a
发帖数: 14
8
O(N)????
诚心求指点.

【在 v***a 的大作中提到】
:
: Sort 不就行了,integer 有好几个O(N)的sort吧

p*****2
发帖数: 21240
9

大牛给讲讲。

【在 v***a 的大作中提到】
:
: Sort 不就行了,integer 有好几个O(N)的sort吧

c****p
发帖数: 6474
10
我猜是counting sort

【在 p*****2 的大作中提到】
:
: 大牛给讲讲。

相关主题
A家面试题T problem
书上关于search和sorting的部分 应该不用全看吧?一个NxN矩阵每行每列都sort好,如何排序?
问几道面试题一个特别的inplace merge two sorted arrays
进入JobHunting版参与讨论
v***a
发帖数: 365
11

我不是大牛,只是提供的自己的想法,
bucket sort, radix sort, counting sort, 貌似都是O(N)的
http://en.wikipedia.org/wiki/Integer_sorting

【在 p*****2 的大作中提到】
:
: 大牛给讲讲。

c**********e
发帖数: 2007
12

Given sequence 1 10 100 1000 ...,which sort you mentioned is O(n)?

【在 v***a 的大作中提到】
:
: 我不是大牛,只是提供的自己的想法,
: bucket sort, radix sort, counting sort, 貌似都是O(N)的
: http://en.wikipedia.org/wiki/Integer_sorting

t****y
发帖数: 27
13
similar to binary radix sort, from highest bit to lowest bit, and no
need to sort the lowest bit. This is an O(n) solution

numbers

【在 a**********2 的大作中提到】
: Given an array of integers where some numbers repeat 1 time, some numbers
: repeat 2 times and only one number repeats 3 times, how do you find the
: number that repeat 3 times. Using hash was not allowed
: 有什么巧解吗?

k***t
发帖数: 276
14
可能是些初级问题:Binary Radix Sort 是O(N)还是O(NLogN)?
扫一遍,分两份,N,再对两份分别递归2*F(N/2)。
F(n)=2*F(n/2)+n 不是典型的O(NLogN)吗?
或者说是N*KeyBitLength,对4G个数是32N也等于N*Log(N)=N*Log(4G)=32N。
有何标准说法?
再有,递归时占用的栈空间算空间复杂时如何算?
请教了,谢谢。

【在 t****y 的大作中提到】
: similar to binary radix sort, from highest bit to lowest bit, and no
: need to sort the lowest bit. This is an O(n) solution
:
: numbers

k***t
发帖数: 276
15
看了一下,可能是这样。
Radix Sort:O(NumOfPassess*N)
Binary Radix Sort:NumOfPasses=LogN,当待排元素集接近所有穷尽时。

【在 k***t 的大作中提到】
: 可能是些初级问题:Binary Radix Sort 是O(N)还是O(NLogN)?
: 扫一遍,分两份,N,再对两份分别递归2*F(N/2)。
: F(n)=2*F(n/2)+n 不是典型的O(NLogN)吗?
: 或者说是N*KeyBitLength,对4G个数是32N也等于N*Log(N)=N*Log(4G)=32N。
: 有何标准说法?
: 再有,递归时占用的栈空间算空间复杂时如何算?
: 请教了,谢谢。

k***t
发帖数: 276
16
基本类似,只不过是Binary Radix Sort,而且是
从most-significant-digit(bit)开始。
t****y
发帖数: 27
17
Binary Radix Sort: #of bits *N

【在 k***t 的大作中提到】
: 看了一下,可能是这样。
: Radix Sort:O(NumOfPassess*N)
: Binary Radix Sort:NumOfPasses=LogN,当待排元素集接近所有穷尽时。

t****y
发帖数: 27
18
The tree height is bounded to a constant value. so we cannot use mast theory
to analyze its complexity

【在 k***t 的大作中提到】
: 可能是些初级问题:Binary Radix Sort 是O(N)还是O(NLogN)?
: 扫一遍,分两份,N,再对两份分别递归2*F(N/2)。
: F(n)=2*F(n/2)+n 不是典型的O(NLogN)吗?
: 或者说是N*KeyBitLength,对4G个数是32N也等于N*Log(N)=N*Log(4G)=32N。
: 有何标准说法?
: 再有,递归时占用的栈空间算空间复杂时如何算?
: 请教了,谢谢。

TN
发帖数: 1870
19
clsr上典型阿,

【在 v********a 的大作中提到】
: O(N)????
: 诚心求指点.

k***t
发帖数: 276
20
这个题用大家说的(binary) Radix Sort的话,又没有shortcut在全部sort完前
提前判断重复3次的数?提前结束程序。

【在 a**********2 的大作中提到】
: Given an array of integers where some numbers repeat 1 time, some numbers
: repeat 2 times and only one number repeats 3 times, how do you find the
: number that repeat 3 times. Using hash was not allowed
: 有什么巧解吗?

相关主题
数组中找和为0的3个数,4个数问个经典问题的improvement
lint code 这个counter numbers smaller than me问两道微软题
google phone interview question一道面试题
进入JobHunting版参与讨论
c*******g
发帖数: 8
21
这道题前几天刚见过, 参见牛人的解答
http://blog.renren.com/share/171828317/11349726763
c*******g
发帖数: 8
22
这么牛x的答案, 居然没人顶, 失望啊
e***s
发帖数: 799
23

不解,不用SORT吧,BIT ARRAY 不行吗?

【在 f*******t 的大作中提到】
: 今天我面A家,三哥问了我这道题。
: 不过一开始是只有一个数出现奇数次,其它出现偶数次,我就说用异或解决。
: 然后他又换了个条件,一个数出现偶数次,其它出现奇数次,其实这个网上有用异或解
: 的代码,我一时实在找不出来,没看懂+记不住。提到hash他又说不能用,最终说了一
: 个暴力解法一个sort解法,他说sort就是想要的。

z*y
发帖数: 1311
24

顶一个
没想到异或,确实牛

【在 c*******g 的大作中提到】
: 这么牛x的答案, 居然没人顶, 失望啊
s****a
发帖数: 528
25
对此题不合适!!!
1 (共1页)
进入JobHunting版参与讨论
相关主题
问两道微软题再来问题
一道面试题A家面试题
A facebook interview question书上关于search和sorting的部分 应该不用全看吧?
求问Jane Street一道面试题问几道面试题
请教一个面试题T problem
Facebook Puzzle Gattaca一个NxN矩阵每行每列都sort好,如何排序?
再问一道题一个特别的inplace merge two sorted arrays
问一个CareerCup上的题数组中找和为0的3个数,4个数
相关话题的讨论汇总
话题: sort话题: radix话题: repeat话题: binary话题: times