leetcode--010 Linked List Cycle II
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAApAAAACICAIAAADfzUzYAAANeklEQVR4nO3dQa7bthbG8W4mK/A+soS3Ao66gK6Aky6i84JbeAgCZBQIyKyvHb6BRk2TIAlw4w5kSyR1DknZkqVz7/+HDGJbIimK4mfRdvLTGQAAHN5PezcAAADUEdgAABhAYAMAYACBDQCAAQQ2AAAGENgAABhAYAMAYACBDQCAAQQ2AAAGENgAABhAYAMAYACBDQCAAQQ2AAAGENgAABhwS2D/72r11gAAABGBDQCAAQQ2AAAGENgAABhAYAMAYACBDQCAAQQ2AMCwH09P3z9/+frx07cN/nz9+On75y8/np72PsrzmcAGANj14+np69//bBHVSWz//c8RMpvABgBY9f3zl63Tevjz/fOXvY+VwDau7/sDFvWAYp8xeuxh6OrHW73PH3B7Pa6Nr9vyG+wf2J0/RVzo41fihw821l5tRudPJ9/dWomwa2PVfXBrddCKRWnF3tFLd1qt5gccwjF6bNmlt1Y7V73e++DGRl2nmLT0B3f1vrNZo60buck885i0Hv6s2/Ib7BvYnT+lF8rsif20j93tAruMwG5DYC+2S2CvKgpspX0H6epDeVmB/ccvr9++ev321ev3bypPEtjns3KVRKf0MnqyzaKHfXDzO/POn1zoxleU4RHtqrxFmN/maiXPWlRq3jlaU3AhtN5hz8qKnijNNH1wQy3SjvOyfZeflulRVlS1n6Vig7i91lFph8h1Le3kcl3RNN8HFx35NBIXHEJL52/UY9EmSihNhzrbMp24W85O3M54OC46O9ULreWw88OLFvCUht3S1UvP7Ll4LUtbLhvt2YE/5rxnte41z9x5h/3Xh//Ms1l88qUHdstSswt9dmbHB8mbtTTmp4uz8+IpnpXYlJpaydfSoileb17+vr6p6ri9ychumreyGa+lVcqFlF3b1X5WDzbaXmtS1iHqvknHVDq5Xtc0nXXeOTc/DUsOobHzt+qx/DJJTux4oOIFNY7AxWdHeJ+T75ufQCmwpQOXrwLF8jvsjc9s+VpW+7NhtOf7Puq855251zxDYFesE9jxh0yy5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uI1lHOOnL7cIYkw/slJXtfVp5sUDxo/DiSOAOG0Bm98DejPgFI5hzxOBq+mADANb1bAM7+hQTpiSLw8f86hWBDWAHzzGwh4XG403zaFT9zGBvBDaAHTzHwAYA4NkhsAEAMIDABgDAAAIbAAADCGwAAAwgsAEAMIDABgDAAAIbAAADCGwAAAwgsAEAMIDABgDAAAIbAAADCGwAAAwgsAEAMIDABgDAAAIbAAADCGwAAAwgsAEAMIDABgDAgFsCGwAAPBiBDQCAAQQ2AAAGENgAABhAYAMAYACBDQCAAQQ2AAAGENgAABjwL9GDGd9rfuNyAAAAAElFTkSuQmCC" alt="" />
public ListNode detectCycle(ListNode head) {
ListNode s=head;
ListNode f=head;
while(f!=null&&f.next!=null){
s=s.next;
f=f.next.next;
if(s==f){
break;
}
}
if(f==null||f.next==null)
return null;
s=head;
while(s!=f){
s=s.next;
f=f.next;
}
return s;
}
leetcode--010 Linked List Cycle II的更多相关文章
- Java for LeetCode 142 Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- [Leetcode Week6]Linked List Cycle II
Linked List Cycle II 题解 题目来源:https://leetcode.com/problems/linked-list-cycle-ii/description/ Descrip ...
- 【Leetcode】Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- [LeetCode] 142. Linked List Cycle II 链表中的环 II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- [LeetCode] 142. Linked List Cycle II 单链表中的环之二
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To r ...
- 【题解】【链表】【Leetcode】Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- (链表 双指针) leetcode 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To r ...
- leetcode 142. Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...
- 【leetcode】Linked List Cycle II (middle)
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- leetcode 142. Linked List Cycle II ----- java
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note ...
随机推荐
- CodeForces 689C Mike and Chocolate Thieves (二分最大化最小值)
题目并不难,就是比赛的时候没敢去二分,也算是一个告诫,应该敢于思考…… #include<stdio.h> #include<iostream> using namespace ...
- Nape实现坐标旋转角度回弹
乒乓球以一个向量运动,碰到障碍后反弹以一个新的向量运动,如下图: 要实现回弹只需要求出向量v1,把向量v0取反,再旋转(a+b)度就可以得到向量v1. 向量取反: var v:vec2 = new V ...
- Mybatis学习(5)高级映射
需求: 一.一对一查询 查询订单信息,关联查询创建订单的用户信息: orders--->user:一个订单只由一个用户创建,一对一 orders表 和 user表: 1)使用resultType ...
- php 连接 mssql sql2008
摘要 sql server 2008 1.下载微软提供的dll 下载地址:http://www.microsoft.com/en-us/download/details.aspx?id=20098 p ...
- 转载 C++学习第9篇---类和类的封装
http://blog.csdn.net/zuheyawen/article/details/7324340
- Ubuntu安装完后设置root密码
安装完Ubuntu 14.04后默认是没有主动设置root密码的,也就无法进入根用户. 相关阅读: Ubuntu 14.04 下载.安装.配置 整理汇总 页面 http://www.linuxidc. ...
- android app开发
android 中文文档: http://www.android-doc.com/training/index.html 二维码在线自动生成.http://www.liantu.com/
- Qt5:无边框窗口拖动
在窗口程序中,无边框窗口程序一般需要特殊处理才能拖动 Qt中,要实现无边框窗口的拖动,需要重新实现 mousePressEvent 和 mouseMoveEvent 俩虚函数 void Widget: ...
- USACO Section 1.1 Broken Necklace 解题报告
题目 题目描述 有一串项链,它是由红蓝白三种颜色的珠子组成的,b代表蓝色,w代表白色,r代表红色,当它完整的时候是一个闭合的环形.现在它在某一个节点断裂了,之前的环形也随之变成了直线形.从两端开始收集 ...
- sql server 2008 把远程的数据库的数据转移到本地数据数据库里
如题:把远程的数据库对应表里的数据转移到本地数据数据库的对应表里 比如把192.168.188.160的DB的A表的数据转移到本地的DB的A表里 第一步:连接远程服务器前准备 exec sp_addl ...