网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  leetcode-006 detect cycle

leetcode-006 detect cycle

分类: IT文章 • 2025-01-26 19:14:55
 1 package leetcode;
 2 
 3 public class DetectCycle {
 4     public ListNode detectCycle(ListNode head) {
 5         ListNode s=head;
 6         ListNode f=head;
 7         while(f!=null&&f.next!=null){
 8             s=s.next;
 9             f=f.next.next;
10             if(s==f){
11                 break;
12             }
13         }
14         if(f==null||f.next==null)
15             return null;
16         s=head;
17         while(s!=f){
18             s=s.next;
19             f=f.next;
20         }
21         return s;
22     }
23 }

相关推荐

  • Linked List Cycle II
  • leetcode 141. Linked List Cycle
  • [LeetCode]Link List Cycle II
  • [LeetCode]Link List Cycle
  • leetcode------Linked List Cycle II
  • 【LeetCode & 剑指offer刷题】链表题6:23 有环链表问题-链表中环的入口结点(141. Linked List Cycle)
  • 代理arp的深入学习和实践实验 Gratuitous ARP Address Conflict Detect Windows系统主机的地址冲突检测实现情况 华三交换机路由器防火墙 处理IP地址冲突处理机制
  • 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)
  • HDU4714 Tree2cycle 解题报告
  • Leetcode OJ: Linked List Cycle I/II
  • 摄像机
  • 从零开始学习jQuery (一) 入门篇
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

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