class Solution {
public:
ListNode* FindFirstCommonNode( ListNode* pHead1, ListNode* pHead2) {
ListNode* cut1 = pHead1;
ListNode* cut2 = pHead2;
while(cut1 != cut2)
{
cut1 = cut1==nullptr ? pHead2 : cut1->next;
cut2 = cut2==nullptr ? pHead1 : cut2->next;
}
return cut1;
}
};

京公网安备 11010502036488号