leetcode之Linked List Cycle
来源:互联网 发布:什么叫java参数传递 编辑:程序博客网 时间:2024/05/02 02:22
/** * 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) { ListNode first=head; ListNode second=head; if(head == null || head.next == null){ return false; } first=first.next; second=second.next.next; while(first!=second && first!=null && second!=null){ first=first.next; if(second.next == null){ return false; } second=second.next.next; } if(first == null || second == null){ return false; } return true; }
0 0
- leetcode 之 Linked List Cycle
- LeetCode之Linked List Cycle
- LeetCode之Linked List Cycle
- leetcode之Linked List Cycle
- leetcode之Linked List Cycle
- leetcode之Linked List Cycle
- LeetCode之Linked List Cycle
- 【LeetCode】之Linked List Cycle
- leetcode之Linked List Cycle
- LeetCode 之 Linked List Cycle
- leetcode之linked List cycle && linked List cycle II
- leetcode Linked List Cycle & Linked List Cycle ||
- LeetCode之Linked List Cycle II
- LeetCode之Linked List Cycle II
- leetcode之Linked List Cycle II
- leetcode之Linked List Cycle II
- LeetCode之Linked List Cycle II
- leetcode之Linked List Cycle II
- HDU 4745 Two Rabbits
- [LeetCode]Min Stack
- 软件工程作业2---小游戏
- 索隆的难题
- iOS分辨率的那些事儿
- leetcode之Linked List Cycle
- 做UIWebView时明白的一些问题
- 用Python开始机器学习(3:数据拟合与广义线性回归)
- 排序算法总结
- 第十二周项目3(4)
- Ubuntu 安装 基于XMPP的Profanity
- 《黑客免杀攻防》 软件逆向工程(4)
- android:windowSoftInputMode属性详解 避免输入法面板遮挡问题
- 第12周项目4 银行系统(1、基本框架)