力扣160 相交链表
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) {
struct ListNode *p=headA;
struct ListNode *q=headB;
if(!p)return p;
if(!q)return q;
while(q!=p){
p=p==NUll?headB:p->next;
q=q==NULL?headA:q->next;
}
return p;
}