struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
struct ListNode*point1=headA;
struct ListNode*point2=headB;
if(headA==NULL||headB==NULL)
{
return NULL;
}
while(point2!=NULL)
{ point1=headA;
while(point1!=NULL)
{
if(point1==point2)
{
return point2;
}
point1=point1->next;
}
point2=point2->next;
}
return NULL;
}
力扣公式题:相交链表
最新推荐文章于 2024-08-21 10:11:50 发布