Java实现-带环链表
来源:互联网 发布:meanshift 聚类算法 编辑:程序博客网 时间:2024/06/05 03:38
/** * Definition for ListNode. * public class ListNode { * int val; * ListNode next; * ListNode(int val) { * this.val = val; * this.next = null; * } * } */ public class Solution { /** * @param head: The first node of linked list. * @return: True if it has a cycle, or false */ public boolean hasCycle(ListNode head) { // write your code here if(head==null||head.next==null){return false;}ListNode first=head;ListNode second=head;while(second.next!=null&&second.next.next!=null){if(first.next==second.next.next){return true;}else{first=first.next;second=second.next.next;}}return false; }}
阅读全文
0 1
- Java实现-带环链表
- 带环的链表
- 带环的链表
- 带环的链表
- 带环的链表
- 带环链表
- 带环链表
- 题目:带环链表
- 带环的链表
- 带环链表
- LinCode_102_带环链表
- 带环链表
- 判断带环链表
- lintcode-带环链表
- lintcode,带环链表
- 带环链表
- 带环链表
- 带环链表-LintCode
- 关于zoom的缩放
- Git常用命令
- 软件工程之版本控制工具Git,SVN
- 1.easyopenjtag使用教程
- 数据仓库C
- Java实现-带环链表
- Java泛型温习
- TCP/IP四层模型
- Android Studio——设置不同的风格
- 广播接收者——案例:拦截有序广播
- 设计模式->行为型模式->模版方法模式
- New Year Table
- Android 学习笔记-布局2
- Android布局