找回密码
 立即注册
搜索
总共850条微博

动态微博

查看: 1872|回复: 2
打印 上一主题 下一主题
收起左侧

classical IT job interview problem

[复制链接]

5

主题

168

帖子

1193

积分

跳转到指定楼层
楼主
发表于 2005-12-18 22:55:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

 
回复

使用道具 举报

0

主题

3

帖子

18

积分

沙发
发表于 2005-12-21 11:26:19 | 只看该作者

回复:classical IT job interview problem


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

 
回复 支持 反对

使用道具 举报

5

主题

168

帖子

1193

积分

板凳
 楼主| 发表于 2005-12-21 16:02:43 | 只看该作者

回复:回复:classical IT job interview problem


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

 
回复 支持 反对

使用道具 举报

24小时热帖
    一周热门
      原创摄影
        美食美文
          您需要登录后才可以回帖 登录 | 立即注册

          本版积分规则

          Archiver|手机版|珍珠湾ART

          Powered by Discuz! X3 © 2001-2013 All Rights Reserved