题目:
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2 ↘ c1 → c2 → c3 ↗ B: b1 → b2 → b3
begin to intersect at node c1.
思路:我们先分别遍历两个链表并得到它们的长度,并求出两个长度之差,长的链表先遍历长度之差之后,两个链表同时开始遍历,直到找到相同的节点,或者到一个链表遍历到最后
代码: