码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode--009 Linked List Cycle I

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

标签:style   blog   color   io   ar   div   new   amp   

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

标签:style   blog   color   io   ar   div   new   amp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!