/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *findFirstCommonNode(ListNode *headA, ListNode *headB) {
auto a=headA,b=headB;
while(a!=b)
{
if(a)a=a->next;
else a=headB;
if(b)b=b->next;
else b=headA;
}//寻找距离一定,一头空插入另一头
return a;
}
};
kk
我去,直击灵魂