/*
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};*/
class Solution {
public:
ListNode* FindFirstCommonNode( ListNode* pHead1, ListNode* pHead2) {
ListNode *travel1 = pHead1, *travel2 = pHead2;
while (travel1 != travel2) {
travel1 == nullptr? travel1=pHead2: travel1=travel1->next;
travel2 == nullptr? travel2=pHead1: travel2=travel2->next;
}
return travel1;
}
};

京公网安备 11010502036488号