由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一道的算法题(五个包子答谢)
相关主题
问个算法题, 关于区间 overlap的G家已挂 分享一下面经
问个Facebook 电面题g phone interv--有没有o(n) 解法
讨论一道面试题问个概率面试题
问一道题(2)间隔五个月,被同一公司同一个人面试。。。
问一道 facebook 面试题Probability quesiton
divide array into two, sum of difference is min in O(N)FB interview question
CLRS上的interval search问题Interval tree解法
请教亚麻一道onsite面试题leetcode 这题insert interval怎么做?
相关话题的讨论汇总
话题: 间隔话题: tree话题: interval话题: between话题: each
进入JobHunting版参与讨论
1 (共1页)
W*******e
发帖数: 1268
1
一排符号排成环形,每种符号必须且只出现两次
比如 1231352454排成一个环形,454后面接着就是前面的123,里面每个符号都出现两次
现在计算相同符号之间的间隔,比如从1开始,找最近的另外一个1的位置,中间间隔了
2个数,结果是2
然后把两个1从环中去掉,剩下的仍然是个环,继续求2之间的间隔(不包括原来的1)
。然后反复这样操作直到环为空,求nlogn的数据结构/算法得到最后所有间隔的累加值
,例如(1的间隔+2的间隔+3的间隔+。。。)
这个问题似乎已经超出了普通的data structure求解范围
x***y
发帖数: 633
2
I think you can use interval tree
first, break circle to list, and duplicate and append.
for each number, we have 4 as the original flatted circle duplicated,and we only care
about the distance between 1st and 2nd, also between 2nd and 3rd, which is
smaller.
second, create the interval tree according the index, the value of each node
in the tree is real distance between 2 edge leaves; wheneve a number is
kicked out, each node on the way down to it will have the value decreased by
1. In interval tree, this is log(n). Get the new distance between any 2
leaves are also log(n) in interval tree.
So, each kicking out will be log(n), for n numbers, it will be o(nlogn).
1 (共1页)
进入JobHunting版参与讨论
相关主题
leetcode 这题insert interval怎么做?问一道 facebook 面试题
leetcode的online judge runtime error是指什么?divide array into two, sum of difference is min in O(N)
新鲜G面筋(Fail)CLRS上的interval search问题
把n个interval 放到一个container里请教亚麻一道onsite面试题
问个算法题, 关于区间 overlap的G家已挂 分享一下面经
问个Facebook 电面题g phone interv--有没有o(n) 解法
讨论一道面试题问个概率面试题
问一道题(2)间隔五个月,被同一公司同一个人面试。。。
相关话题的讨论汇总
话题: 间隔话题: tree话题: interval话题: between话题: each