由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - 面试题: 怎么判断一个linked list 是不是 circled
相关主题
[合集] 面试题: 怎么判断一个linked list 是不是 circled[合集] How to model this problem?(probability)
问个统计的面试题如何用binomial tree对one touch option定价
我愚钝,reverse linked list的code我看不懂,谁给我解释解释a data structure question (easy level)
[合集] 大家帮忙想想一个算法题.问个关于binomial tree的问题
有没有什么算法能够输出一个graph的两个nodes之间的所有路径?问个C++的问题
[合集] 来个C++的题求指教,要不要从了offer?
问个简单的C++问题问一个graph题 (转载)
[合集] interview question(programming)请教用R怎样实现一个binary tree的class
相关话题的讨论汇总
话题: circled话题: linked话题: list话题: 面试题话题: node
进入Quant版参与讨论
1 (共1页)
y***n
发帖数: 6764
1
只能用有限的variable.
s*****g
发帖数: 3
2
set p as the starting point, then
go through the linked list and check whether current point is eq p.
stop until you get back to p or you get to the end of the list.
am I right?
r*********r
发帖数: 3195
3
i got asked this question in my phone interview, which i got it right:
color all the nodes white first,
then each node you visit, color it black,
when you see a node whose "next" field is a black node,
you got a circle.
there is a follow-up question to this one, which is harder. :)
p*u
发帖数: 2454
4
要是node不能碰你怎么办,傻眼了??

【在 r*********r 的大作中提到】
: i got asked this question in my phone interview, which i got it right:
: color all the nodes white first,
: then each node you visit, color it black,
: when you see a node whose "next" field is a black node,
: you got a circle.
: there is a follow-up question to this one, which is harder. :)

r*********r
发帖数: 3195
5
那就另用一个hash table, 作指针到颜色的映射。
不过这个的内存开销是线性的。
所以原题的标准答案还是一快一慢两个指针的龟兔算法。
如果没见过答案的话,很怀疑谁能在电话上想出来。
我答的是用 bloom filter, 这样内存开销可以减小,
但是可能有false positive。
interviewer 也就没有纠缠下去。
1 (共1页)
进入Quant版参与讨论
相关主题
请教用R怎样实现一个binary tree的class有没有什么算法能够输出一个graph的两个nodes之间的所有路径?
面试题讨论: three variables correlation coefficients有不求特征值的快速判断法吗?[合集] 来个C++的题
MS面试题问个简单的C++问题
问面试题[合集] interview question(programming)
[合集] 面试题: 怎么判断一个linked list 是不是 circled[合集] How to model this problem?(probability)
问个统计的面试题如何用binomial tree对one touch option定价
我愚钝,reverse linked list的code我看不懂,谁给我解释解释a data structure question (easy level)
[合集] 大家帮忙想想一个算法题.问个关于binomial tree的问题
相关话题的讨论汇总
话题: circled话题: linked话题: list话题: 面试题话题: node