网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  leetcode--010 Linked List Cycle II

leetcode--010 Linked List Cycle II

分类: IT文章 • 2025-01-26 19:02:07

leetcode--010 Linked List Cycle II

 1 public ListNode detectCycle(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                 break;
 9             }
10         }
11         if(f==null||f.next==null)
12             return null;
13         s=head;
14         while(s!=f){
15             s=s.next;
16             f=f.next;
17         }
18         return s;
19     }

相关推荐

  • Linked List Cycle II
  • leetcode 141. Linked List Cycle
  • [LeetCode]Link List Cycle II
  • leetcode------Linked List Cycle II
  • 【LeetCode & 剑指offer刷题】链表题6:23 有环链表问题-链表中环的入口结点(141. Linked List Cycle)
  • Leetcode OJ: Linked List Cycle I/II
  • 141. Linked List Cycle Problem statement Solution
  • leetcode--010 Linked List Cycle II
  • leetcode--009 Linked List Cycle I
  • 判断链表是否有环,如果有,找到环的入口位置 Linked List Cycle Linked List Cycle II 求环的长度
  • Python 线程(六):Timer(定时器)
  • JAVA课程设计-计算器(201521123028 李家俊)
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号