标签:
原题链接:https://leetcode.com/problems/linked-list-cycle/
题目:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
思路:
两个指针,一个移动一步,一个移动两步,所以两个指针相对距离每移动一次就加一,如果有循环,一定可以在 循环长度/(2-1) 个循环后相遇,没有循环则会遇到null
算法:
标签:
原文地址:http://blog.csdn.net/yeqiuzs/article/details/51606453