珍珠湾ART

标题: classical IT job interview problem [打印本页]

作者: QL    时间: 2005-12-18 22:55
标题: classical IT job interview problem

Given a singly linked list with n nodes (n is not given), you are asked to check whether there is a loop in the linked list. Can you design a program to do that with constant number of extra memories (independent of n) and O(n) in time? The linked list is read-only.
www.ddhw.com

 

作者: sadfsdfsdfsd    时间: 2005-12-21 11:26
标题: 回复:classical IT job interview problem

two pointer, one step 1 everytime, the other step two every time.
www.ddhw.com

 

作者: QL    时间: 2005-12-21 16:02
标题: 回复:回复:classical IT job interview problem

Right. Similar idea was used in constant's problem: 程序竞赛
www.ddhw.com

 





欢迎光临 珍珠湾ART (http://zzwav.com/) Powered by Discuz! X3