Skip to content

Commit cd74c61

Browse files
authored
Update Explain.md
1 parent 34814af commit cd74c61

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

160. Intersection of Two Linked Lists/Explain.md

+13
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,17 @@ headB : 5 0 1 8 4 5 null 4 1 8 4 5
1212

1313
這時候會發現,他們第一次intersection的node不是"1"嗎?
1414
為甚麼答案是"8"呢?
15+
16+
1517
用gdb看一下
18+
19+
20+
![image](https://github.com/CY-Gu/leetcode/blob/master/160.%20Intersection%20of%20Two%20Linked%20Lists/when%201.PNG)
21+
22+
會發現其實這兩個"1"雖然val一樣,但他們pointer不一樣,也就是說這兩個其實是不同的node,所以不可能會相遇
23+
24+
那再看一下"8"這個node
25+
26+
![image](https://github.com/CY-Gu/leetcode/blob/master/160.%20Intersection%20of%20Two%20Linked%20Lists/when%208.PNG)
27+
28+
可以看到它們無論val還是pointer都是相同的,它們才是真正會相遇的共同node

0 commit comments

Comments
 (0)