![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
list
jan_deng
这个作者很懒,什么都没留下…
展开
-
LeetCode OJ 160. Intersection of Two Linked Lists
LeetCode OJ 160. Intersection of Two Linked ListsDescriptionWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A:原创 2017-03-21 19:48:18 · 201 阅读 · 0 评论 -
LeetCode OJ 141. Linked List Cycle
LeetCode OJ 141. Linked List CycleDescriptionGiven a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?解题思路对于判断环的问题,可以采用双指针(快慢指针)的方法来判断。另外,因为题目中给的Lis原创 2017-03-21 20:30:41 · 235 阅读 · 0 评论 -
NowCoder 剑指Offer_编程题 链表中环的入口节点
NowCoder 链表中环的入口节点Description一个链表中包含环,请找出该链表的环的入口结点。解题思路两个指针p,q从表头出发遍历链表,p每次走一步,q每次走两步。如果链表中有环,那么p,q最终会相遇。设p走了x步,q则走了2x,设环的长度为n,表头到环的入口节点距离为k。那么会有等式2x-x=n,即x=n,即p走过的路程为环的长度。设p此时走了环的距离为d(从入口节点开始算),那么就有k原创 2017-03-22 13:42:30 · 313 阅读 · 0 评论