/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
struct ListNode*point1=headA;
struct ListNode*point2=headB;
while(point1!=NULL)
{
point2=headB;
while(point2!=NULL)
{
if(point1==point2)
{
return point1;
}
point2=point2->next;
}
point1=point1->next;
}
return NULL;
}
力扣经典题:相交链表
最新推荐文章于 2024-08-21 10:11:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)