Linked List Cycle
来源:互联网 发布:超级优化女主角有谁 编辑:程序博客网 时间:2024/06/11 00:35
/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class Solution { public boolean hasCycle(ListNode head) { if (head == null) { return false; } ListNode dummy = new ListNode(-1); dummy.next = head; ListNode fast = dummy; ListNode slow = dummy; while (fast.next != null && fast.next.next != null) { fast = fast.next.next; slow = slow.next; if (slow == fast) { return true; } } return false; }}
0 0
- leetcode Linked List Cycle & Linked List Cycle ||
- Linked List Cycle II Linked List Cycle
- 【LeetCode】Linked List Cycle
- Leetcode: Linked List Cycle
- Leetcode Linked List Cycle
- Linked List Cycle
- Linked List Cycle II
- Linked List Cycle
- Linked List Cycle
- Linked List Cycle II
- Leetcode: Linked List Cycle
- LeetCode:Linked List Cycle
- Linked List Cycle II
- Linked List Cycle
- Linked List Cycle II
- [LeetCode]Linked List Cycle
- Linked List Cycle
- LeetCode | Linked List Cycle
- HDU 1021 Fibonacci Again
- 关于渗透测试过程中的SSH免登陆
- Android开发之颜色对照表
- 2015.7.7 第二课 课程重点(表单)
- 让多核CPU占用率曲线听你指挥(Linux实现)——《编程之美》1.1继续学习
- Linked List Cycle
- HDU 1051 Wooden Sticks
- 嘻唰唰第一批之商品销售之静态运用
- PayPal高级工程总监:读完这100篇论文 就能成大数据高手
- 《高效程序员的45个习惯》notes
- JAVA基础----集合
- IOS中http请求的cookie查看,删除,添加
- [Win32SDK基本] Combo Box
- 数据库进行外键关联失败的解决方法