首页 > 其他 > 详细

leetcode--009 Linked List Cycle I

时间:2014-07-31 16:14:27      阅读:337      评论:0      收藏:0      [点我收藏+]

bubuko.com,布布扣

 

 

 1 public boolean hasCycle(ListNode head) {
 2         ListNode s=head;
 3         ListNode f=head;
 4         while(f!=null&&f.next!=null){
 5             s=s.next;
 6             f=f.next.next;
 7             if(s==f){
 8                 return true;
 9             }
10         }
11             return false;
12         
13     }

 

leetcode--009 Linked List Cycle I,布布扣,bubuko.com

leetcode--009 Linked List Cycle I

原文:http://www.cnblogs.com/thehappyyouth/p/3880640.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!