/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
auto p=headA,q=headB;
while(p!=q)
{
if(!q) q=headA;
else q=q->next;
if(!p) p=headB;
else p=p->next;
}
return p;
}
};
标签:ListNode,int,next,链表,headB,headA,160,LeetCode
From: https://www.cnblogs.com/tangxibomb/p/17529554.html