由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 算法题
相关主题
谁来解释下hashtable的iterator是怎么实现的A facebook interview question
hashtable的遍历贡献两个Amazon的电话面试题
问道大数据的题贡献一个groupon的电面题
大家总是说工作中不会用到算法求祝福, Google phone screen exposed
Bloomberg 电面问几道题目
hash_map 的遍历问题考古--用户最多的3连击问题
an interview question, find mode in a rolling window along data sequence我发现我竟然学会了12种tree traversal的办法
考古到一道题请问怎样写没有parent pointer的BST iterator?
相关话题的讨论汇总
话题: time话题: 算法话题: step话题: bucket话题: each
进入JobHunting版参与讨论
1 (共1页)
p*******o
发帖数: 3564
1
今早在careercup上看到,http://www.careercup.com/question?id=12523672
Assume we have n people. Each one has a starting time and ending time. For
any people, set flag to true if his/her time range overlaps with anyone else
's.
假设完全没有排序,怎么搞O(N)算法,下面讨论中所谓的Hashtable bucket是什么意思
,如何实现
a******a
发帖数: 2646
2
应该有nlgn 算法
struct person
{ start time
end time
}
读入person
按start time binary排序,是 nlgn
如果重叠,修改
struct, 另
person.start =min
person.end =max
合并成为一个记录。
m*******l
发帖数: 12782
3
他要的是O(n)阿

【在 a******a 的大作中提到】
: 应该有nlgn 算法
: struct person
: { start time
: end time
: }
: 读入person
: 按start time binary排序,是 nlgn
: 如果重叠,修改
: struct, 另
: person.start =min

H****s
发帖数: 247
4
Step 1: Find the latest start time and the earliest finish time during the
first iteration.
Step 2:Compare each interval with the two numbers got from the first step
during the second iteration.
Two iterations with run time O(n)

【在 m*******l 的大作中提到】
: 他要的是O(n)阿
w***g
发帖数: 5958
5
我觉得没有O(N)的算法。

else

【在 p*******o 的大作中提到】
: 今早在careercup上看到,http://www.careercup.com/question?id=12523672
: Assume we have n people. Each one has a starting time and ending time. For
: any people, set flag to true if his/her time range overlaps with anyone else
: 's.
: 假设完全没有排序,怎么搞O(N)算法,下面讨论中所谓的Hashtable bucket是什么意思
: ,如何实现

p*****2
发帖数: 21240
6
如果只是时间的话,没有日期的话,那就是24个小时。如果计算到分钟的话,就是1440
分钟,那么定义这么一个数组。
int[] times=new int[1440];
第一遍扫描的时候如果一个人的start end time 包括这个分钟,就 times[i]++。
第二遍扫描的时候如果这个人的start-end time中有times[i]>1 就说明有overlap。
r****t
发帖数: 10904
7
整数排序

【在 w***g 的大作中提到】
: 我觉得没有O(N)的算法。
:
: else

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

bucket sort可以。先按分钟,再按小时。

【在 r****t 的大作中提到】
: 整数排序
r****t
发帖数: 10904
9
bucket radix sort? hoho

【在 p*****2 的大作中提到】
:
: bucket sort可以。先按分钟,再按小时。

z******w
发帖数: 36
10
嗯,radix sort排序后扫描一遍就可以求出overlap的元素了
1 (共1页)
进入JobHunting版参与讨论
相关主题
请问怎样写没有parent pointer的BST iterator?Bloomberg 电面
L家的高频题merge k sorted arrays giving iterators求讨论!hash_map 的遍历问题
reverse an arrayan interview question, find mode in a rolling window along data sequence
大量数据里面找top 100考古到一道题
谁来解释下hashtable的iterator是怎么实现的A facebook interview question
hashtable的遍历贡献两个Amazon的电话面试题
问道大数据的题贡献一个groupon的电面题
大家总是说工作中不会用到算法求祝福, Google phone screen exposed
相关话题的讨论汇总
话题: time话题: 算法话题: step话题: bucket话题: each