更新图片链接
This commit is contained in:
12
problems/面试题02.07.链表相交.md
Normal file → Executable file
12
problems/面试题02.07.链表相交.md
Normal file → Executable file
@@ -13,7 +13,7 @@
|
||||
|
||||
图示两个链表在节点 c1 开始相交:
|
||||
|
||||

|
||||

|
||||
|
||||
题目数据 保证 整个链式结构中不存在环。
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
|
||||
示例 1:
|
||||
|
||||

|
||||

|
||||
|
||||
示例 2:
|
||||
|
||||

|
||||

|
||||
|
||||
示例 3:
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@
|
||||
|
||||
看如下两个链表,目前curA指向链表A的头结点,curB指向链表B的头结点:
|
||||
|
||||

|
||||

|
||||
|
||||
我们求出两个链表的长度,并求出两个链表长度的差值,然后让curA移动到,和curB 末尾对齐的位置,如图:
|
||||
|
||||

|
||||

|
||||
|
||||
此时我们就可以比较curA和curB是否相同,如果不相同,同时向后移动curA和curB,如果遇到curA == curB,则找到交点。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user